Skip to content
Snippets Groups Projects
Commit 5e9443a4 authored by Markus Blatt's avatar Markus Blatt
Browse files

Support counting even if the pointer type is converted to a compatible

base class.

Previously

class A{};
class B: public A{};

shared_ptr<A> b(new B);
shared_ptr<B> b(a);

b.get_count()==1 && b.get_count()==1 would wrongly hold true.

[[Imported from SVN: r7046]]
parent 450d96a0
No related branches found
No related tags found
No related merge requests found
...@@ -65,6 +65,23 @@ int main(){ ...@@ -65,6 +65,23 @@ int main(){
// test conversion in make_shared // test conversion in make_shared
shared_ptr<A> a=test_make_shared(); shared_ptr<A> a=test_make_shared();
{
shared_ptr<B> b(new B);
a=b;
if(b.use_count()!=2) {
std::cout << "Reference count is wrong! "<<__LINE__<<":"<<
__FILE__<<std::endl;
ret=1;
}
if(a.use_count()!=2) {
std::cout << "Reference count is wrong! "<<__LINE__<<":"<<
__FILE__<<std::endl;
ret=1;
}
}
// print the type of the shared_ptr, so we know whether we are // print the type of the shared_ptr, so we know whether we are
// checking dune's shared_ptr or some std one // checking dune's shared_ptr or some std one
std::cout << "=== checking shared_ptr type: " << className(foo) std::cout << "=== checking shared_ptr type: " << className(foo)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment