C++11's std::shared_ptr<> provides a kind of bool operator.
operator unspecified-bool-type() const;
(It's not a straight-up operator bool() const
due to the dangers from implicit casting of type bool
.)
Why doesn't std::weak_ptr<> have a similar operator? I find myself constantly typing
if( !wp.expired() )
when I want to type
if( wp )
Why no bool conversion for weak_ptr?