]>
git.saurik.com Git - wxWidgets.git/blob - interface/ptr_shrd.h
1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: interface of wxSharedPtr<T>
4 // Author: wxWidgets team
6 // Licence: wxWindows license
7 /////////////////////////////////////////////////////////////////////////////
12 A smart pointer with non-intrusive reference counting. It is modeled after
13 @c boost::shared_ptr and can be used with STL containers and wxVector<T> -
14 unlike @c std::auto_ptr and wxScopedPtr<T>.
17 @category{smartpointers}
19 @see wxScopedPtr<T>, wxWeakRef<T>, wxObjectDataPtr
28 Creates shared pointer from the raw pointer @a ptr and takes ownership
31 wxSharedPtr(T
* ptr
= NULL
);
34 wxSharedPtr(const wxSharedPtr
<T
>& tocopy
);
42 Returns pointer to its object or @NULL.
47 Conversion to a boolean expression (in a variant which is not
48 convertable to anything but a boolean expression). If this class
49 contains a valid pointer it will return @e @true, if it contains
50 a @NULL pointer it will return @e @false.
52 operator unspecified_bool_type() const;
55 Returns a reference to the object. If the internal pointer is @NULL
56 this method will cause an assert in debug mode.
61 Returns pointer to its object or @NULL.
66 Assignment operator. Releases any previously held pointer
67 and creates a reference to @e ptr.
69 wxSharedPtrT
& operator operator=(T
* ptr
);
72 Reset pointer to @e ptr. If the reference count of the
73 previously owned pointer was 1 it will be deleted.
75 void reset(T
* ptr
= NULL
);
78 Returns @true if this is the only pointer pointing to its object.
83 Returns the number of pointers pointing to its object.
85 long use_count() const;