]> git.saurik.com Git - wxWidgets.git/blobdiff - include/wx/ptr_shrd.h
rename various gsock* files to sock* (except for MSW where this will be done later)
[wxWidgets.git] / include / wx / ptr_shrd.h
index f90f4ec8b12a96c4f292c7f9b9fb310dbb668e3e..71492d9754495cc8386f9ec29e4cd25a5c6917eb 100644 (file)
@@ -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<T>::*unspecified_bool_type)() const;
+    operator unspecified_bool_type() const
+    {
+        if (m_ref && m_ref->m_ptr)
+           return  &wxSharedPtr<T>::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: