29 Jan
2003
29 Jan
'03
7:21 p.m.
"wasekvesely
Hi,
I've found this in "shared_ptr.hpp":
// implicit conversion to "bool" typedef T * (this_type::*unspecified_bool_type)() const;
operator unspecified_bool_type() const // never throws { return px == 0? 0: &this_type::get; }
Why this is better than:
operator bool() const { return px != 0; }
What more can I do with somethin like this?
It's not that you can do more; quite the opposite. int f(long); int x = f(shared_ptr<int>()); // error With operator bool(), that (and many other abuses) would compile. -- David Abrahams dave@boost-consulting.com * http://www.boost-consulting.com Boost support, enhancements, training, and commercial distribution