X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/526954c5968baa29218c994ec48e476ae2bd4b9f..21d0340384a484e3c8e04280de90c0fb8e261006:/interface/wx/sharedptr.h diff --git a/interface/wx/sharedptr.h b/interface/wx/sharedptr.h index 2b18e2a471..8b7087baed 100644 --- a/interface/wx/sharedptr.h +++ b/interface/wx/sharedptr.h @@ -2,14 +2,13 @@ // Name: sharedptr.h // Purpose: interface of wxSharedPtr // Author: wxWidgets team -// RCS-ID: $Id$ // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// /** A smart pointer with non-intrusive reference counting. - It is modeled after @c boost::shared_ptr<> and can be used with STL + It is modelled after @c boost::shared_ptr<> and can be used with STL containers and wxVector unlike @c std::auto_ptr<> and wxScopedPtr. @library{wxbase} @@ -29,6 +28,22 @@ public: */ wxEXPLICIT wxSharedPtr(T* ptr = NULL); + /** + Constructor. + + Creates shared pointer from the raw pointer @a ptr and deleter @a d + and takes ownership of it. + + @param ptr The raw pointer. + @param d Deleter - a functor that is called instead of delete to + free the @a ptr raw pointer when its reference count drops to + zero. + + @since 3.0 + */ + template + wxEXPLICIT wxSharedPtr(T* ptr, Deleter d); + /** Copy constructor. */ @@ -61,7 +76,9 @@ public: T operator*() const; /** - Returns pointer to its object or @NULL. + Smart pointer member access. Returns pointer to its object. + + If the internal pointer is @NULL this method will cause an assert in debug mode. */ T* operator->() const; @@ -87,6 +104,21 @@ public: */ void reset(T* ptr = NULL); + /** + Reset pointer to @a ptr. + + If the reference count of the previously owned pointer was 1 it will be deleted. + + @param ptr The new raw pointer. + @param d Deleter - a functor that is called instead of delete to + free the @a ptr raw pointer when its reference count drops to + zero. + + @since 3.0 + */ + template + void reset(T* ptr, Deleter d); + /** Returns @true if this is the only pointer pointing to its object. */