X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/e39d30c05b9febb396cd9f133b9df7718142e299..f8b1df0b15f843b8f47efb9bee38f1de0fa95020:/include/wx/object.h diff --git a/include/wx/object.h b/include/wx/object.h index df40c11d43..88297d21b8 100644 --- a/include/wx/object.h +++ b/include/wx/object.h @@ -457,6 +457,20 @@ public: T *get() const { return m_ptr; } + // test for pointer validity: defining conversion to unspecified_bool_type + // and not more obvious bool to avoid implicit conversions to integer types + typedef T *(wxObjectDataPtr::*unspecified_bool_type)() const; + operator unspecified_bool_type() const + { + return m_ptr ? &wxObjectDataPtr::get : NULL; + } + + T& operator*() const + { + wxASSERT(m_ptr != NULL); + return *(m_ptr); + } + T *operator->() const { wxASSERT(m_ptr != NULL);