If often find myself using code like this:
boost::scoped_ptr<TFoo> f(new TFoo);
Bar(f.get()); // call legacy or 3rd party function : void Bar (TFoo *)
Now, I think the smart pointers could easily define an implicit conversion operator back to the 'raw' pointer type, which would allow this code to still be valid, and ease the 'smartening' of old code
Bar(f);
But, they don't -or at least, not the ones I've found. Why?
IMO implicit conversion is the root of all evil in c++, and one the toughest kinds of bugs to track down.
It's good practice not to rely on them - you can't predict all behaviours.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With