
29 Apr
2008
29 Apr
'08
6:18 a.m.
I think there are cases not caught by the current assert condition: struct A : boost::enable_shared_from_this<A> {}; int main() { boost::shared_ptr<A> pa; { A a; pa = a.shared_from_this(); boost::shared_ptr<A> pa2( &a ); // here, first 'pa2' and then 'a' goes out of scope! } // now 'pa' still exists and points to a deleted object } What do you think of the following condition: BOOST_ASSERT( _weak_count.use_count() == 0 || _shared_count.use_count() == 1 ); It passes all regression tests and catches the above case. Do you see any problem with it or shall I commit it? Regards, Daniel