diff --git a/include/wx/object.h b/include/wx/object.h index dd1e2fb927..e4baee1396 100644 --- a/include/wx/object.h +++ b/include/wx/object.h @@ -278,6 +278,15 @@ public: m_ptr->IncRef(); } + // generalized copy ctor: U must be convertible to T + template + wxObjectDataPtr(const wxObjectDataPtr &tocopy) + : m_ptr(tocopy.get()) + { + if (m_ptr) + m_ptr->IncRef(); + } + ~wxObjectDataPtr() { if (m_ptr) @@ -330,6 +339,17 @@ public: return *this; } + template + wxObjectDataPtr& operator=(const wxObjectDataPtr &tocopy) + { + if (m_ptr) + m_ptr->DecRef(); + m_ptr = tocopy.get(); + if (m_ptr) + m_ptr->IncRef(); + return *this; + } + wxObjectDataPtr& operator=(T *ptr) { if (m_ptr) diff --git a/interface/wx/object.h b/interface/wx/object.h index 16d4905e74..dc290db79c 100644 --- a/interface/wx/object.h +++ b/interface/wx/object.h @@ -585,11 +585,17 @@ public: */ wxObjectDataPtr(T* ptr = NULL); + //@{ /** This copy constructor increases the count of the reference counted object to which @a tocopy points and then this class will point to, as well. + + Using @a U different from @c T is only supported since wxWidgets 3.1.5. */ + template + wxObjectDataPtr(const wxObjectDataPtr& tocopy); wxObjectDataPtr(const wxObjectDataPtr& tocopy); + //@} /** @@ -649,7 +655,11 @@ public: //@{ /** Assignment operator. + + Using @a U different from @c T is only supported since wxWidgets 3.1.5. */ + template + wxObjectDataPtr& operator=(const wxObjectDataPtr& tocopy); wxObjectDataPtr& operator=(const wxObjectDataPtr& tocopy); wxObjectDataPtr& operator=(T* ptr); //@}