
8 Jun
2009
8 Jun
'09
7:16 p.m.
AMDG Robert Dailey wrote:
Just wondering what happens if I do this:
boost::shared_ptr<Foo> foo; boost::shared_ptr<Bar> bar; if( foo && bar ) { // Do stuff if both pointers are valid... }
I did not see an overloaded && operator in the interface of the class. When using normal pointer semantics, this code is valid through implicit conversion of a pointer value to a boolean type.
The same applies to shared_ptr. http://www.boost.org/libs/smart_ptr/shared_ptr.htm#conversions In Christ, Steven Watanabe