X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/5200ca361e9edef8b7c075f8989b2dbe9c4c7ad8..1a9a6eed360bc9a263f2ea7c0d470953397de531:/include/wx/ptr_shrd.h?ds=sidebyside diff --git a/include/wx/ptr_shrd.h b/include/wx/ptr_shrd.h index f90f4ec8b1..71492d9754 100644 --- a/include/wx/ptr_shrd.h +++ b/include/wx/ptr_shrd.h @@ -55,6 +55,17 @@ public: return *this; } + // test for pointer validity: defining conversion to unspecified_bool_type + // and not more obvious bool to avoid implicit conversions to integer types + typedef T *(wxSharedPtr::*unspecified_bool_type)() const; + operator unspecified_bool_type() const + { + if (m_ref && m_ref->m_ptr) + return &wxSharedPtr::get; + else + return NULL; + } + T& operator*() const { wxASSERT(m_ref != NULL); @@ -83,7 +94,6 @@ public: bool unique() const { return (m_ref ? m_ref->m_count == 1 : true); } long use_count() const { return (m_ref ? (long)m_ref->m_count : 0); } - operator bool() const { return (get() != NULL); } private: