vbl_scoped_ptr mimics a built-in pointer except that it guarantees deletion of the object pointed to, either on destruction of the vbl_scoped_ptr or via an explicit reset(). More...
#include <vbl_fwd.h>
Public Types | |
| typedef T | element_type |
Public Member Functions | |
| vbl_scoped_ptr (T *p=nullptr) | |
| ~vbl_scoped_ptr () | |
| T must be complete when this destructor is instantiated. More... | |
| void | reset (T *p=nullptr) |
Make this own p, releasing any existing pointer. More... | |
| T & | operator * () const |
| T * | operator-> () const |
| T * | get_pointer () const |
| operator bool () const | |
| Safe implicit conversion to bool. More... | |
| bool | operator! () const |
| void | swap (vbl_scoped_ptr &b) |
Private Types | |
| typedef vbl_scoped_ptr< T > | this_type |
Private Member Functions | |
| vbl_scoped_ptr (vbl_scoped_ptr const &)=delete | |
| vbl_scoped_ptr & | operator= (vbl_scoped_ptr const &)=delete |
Private Attributes | |
| T * | ptr_ |
vbl_scoped_ptr mimics a built-in pointer except that it guarantees deletion of the object pointed to, either on destruction of the vbl_scoped_ptr or via an explicit reset().
vbl_scoped_ptr is a simple solution for simple needs; use vbl_shared_ptr or std::unique_ptr if your needs are more complex.
To use this to manage pointer member variables using forward declaration, explicitly define a destructor in your .cxx so that the vbl_scoped_ptr destructor is called there rather than being inlined. For example, Y.h:
Y.cxx:
| typedef T vbl_scoped_ptr< T >::element_type |
Definition at line 67 of file vbl_scoped_ptr.h.
|
private |
Definition at line 62 of file vbl_scoped_ptr.h.
|
privatedelete |
|
inlineexplicit |
Definition at line 70 of file vbl_scoped_ptr.h.
|
inline |
T must be complete when this destructor is instantiated.
Definition at line 77 of file vbl_scoped_ptr.h.
|
inline |
Definition at line 101 of file vbl_scoped_ptr.h.
|
inline |
Definition at line 89 of file vbl_scoped_ptr.h.
|
inlineexplicit |
Safe implicit conversion to bool.
This allows for if (sp) type of usage.
Definition at line 111 of file vbl_scoped_ptr.h.
|
inline |
Definition at line 117 of file vbl_scoped_ptr.h.
|
inline |
Definition at line 95 of file vbl_scoped_ptr.h.
|
privatedelete |
|
inline |
Make this own p, releasing any existing pointer.
Definition at line 83 of file vbl_scoped_ptr.h.
|
inline |
Definition at line 123 of file vbl_scoped_ptr.h.
|
private |
Definition at line 56 of file vbl_scoped_ptr.h.
1.8.15