]> git.saurik.com Git - wxWidgets.git/blob - docs/latex/wx/sharedptr.tex
Added the conversion to unspecfied_bool to all smart pointers, added T& operator...
[wxWidgets.git] / docs / latex / wx / sharedptr.tex
1 \section{\class{wxSharedPtr<T>}}\label{wxsharedptr}
2
3 A smart pointer with non-intrusive reference counting. It is modeled
4 after {\bf boost::shared\_ptr<>} and can be used with STL containers
5 and \helpref{wxVector<>}{wxvector} - unlike {\bf std::auto\_ptr<>}
6 and \helpref{wxScopedPtr<>}{wxscopedptrtemplate}.
7
8 \wxheading{Derived from}
9
10 No base class
11
12 \wxheading{Include files}
13
14 <ptr\_shrd.h>
15
16 \wxheading{Data structures}
17
18 {\small%
19 \begin{verbatim}
20 typedef T element_type
21 \end{verbatim}
22 }%
23
24 \wxheading{See also}
25
26 \helpref{wxScopedPtr}{wxscopedptrtemplate}, \helpref{wxWeakRef}{wxweakref}
27
28
29 \latexignore{\rtfignore{\wxheading{Members}}}
30
31
32 \membersection{wxSharedPtr<T>::wxSharedPtr<T>}\label{wxsharedptrwxsharedptr}
33
34 \func{wxEXPLICIT}{wxSharedPtr<T>}{\param{T* }{ptr = NULL}}
35
36 \func{}{wxSharedPtr<T>}{\param{const wxSharedPtr<T>\& }{tocopy}}
37
38 Constructors.
39
40 \membersection{wxSharedPtr<T>::\destruct{wxSharedPtr<T>}}\label{wxsharedptrdtor}
41
42 \func{}{\destruct{wxSharedPtr<T>}}{\void}
43
44 Destructor.
45
46 \membersection{wxSharedPtr<T>::get}\label{wxsharedptrget}
47
48 \constfunc{T*}{get}{\void}
49
50 Returns pointer to its object or NULL.
51
52 \membersection{wxSharedPtr<T>::operator unspecified\_bool\_type}\label{wxsharedptroperatorbool}
53
54 \constfunc{}{operator unspecified\_bool\_type}{\void}
55
56 Conversion to a boolean expression (in a variant which is not
57 convertable to anything but a boolean expression). If this class
58 contains a valid pointer it will return {\it true}, if it contains
59 a NULL pointer it will return {\it false}.
60
61 \membersection{wxSharedPtr<T>::operator*}\label{wxsharedptroperatorreft}
62
63 \constfunc{T\&}{operator*}{\void}
64
65 Returns a reference to the object. If the internal pointer is NULL this
66 method will cause an assert in debug mode.
67
68 \membersection{wxSharedPtr<T>::operator->}\label{wxsharedptroperatorderef}
69
70 \constfunc{T*}{operator->}{\void}
71
72 Returns pointer to its object or NULL.
73
74 \membersection{wxSharedPtr<T>::operator=}\label{wxsharedptroperatorassign}
75
76 \func{wxSharedPtr<T>\& operator}{operator=}{\param{const wxSharedPtr<T>\& }{tocopy}}
77
78 Assignment operator. Releases any previously held pointer
79 and creates a reference to same object as {\it topcopy}.
80
81 \membersection{wxSharedPtr<T>::operator=}\label{wxsharedptroperatorassign2}
82
83 \func{wxSharedPtr<T>\& operator}{operator=}{\param{T *}{ptr}}
84
85 Assignment operator. Releases any previously held pointer
86 and creates a reference to {\it ptr}.
87
88 \membersection{wxSharedPtr<T>::unique}\label{wxsharedptrunique}
89
90 \constfunc{bool}{unique}{\void}
91
92 Returns true if this is the only pointer pointing to its object.
93
94 \membersection{wxSharedPtr<T>::use\_count}\label{wxsharedptruse\_count}
95
96 \constfunc{long}{use\_count}{\void}
97
98 Returns the number of pointers pointing to its object.
99
100 \membersection{wxSharedPtr<T>::reset}\label{wxsharedptrreset}
101
102 \func{void}{reset}{\param{T * }{ptr = NULL}}
103
104 Reset pointer to {\it ptr}. Afterwards the caller is responsible
105 for deleting the data contained in the pointer before.
106