A smart pointer to any type. More...
#include <keyvalue/util/AnyPtr.h>
Public Member Functions | |
AnyPtr () | |
Default constructor builds a NULL AnyPtr. | |
template<typename T > | |
AnyPtr (T *ptr) | |
Constructor taking a generic (raw) pointer type. | |
template<typename T > | |
AnyPtr (shared_ptr< T > ptr) | |
Constructor taking a shared_ptr<T>. | |
template<typename T > | |
operator shared_ptr< T > () const | |
Automatic cast to shared_ptr<T>. | |
operator bool () const | |
Automatic conversion to bool . | |
void | swap (AnyPtr &other) |
Non throwing swap. | |
Private Member Functions | |
template<typename T > | |
void | thrower () const |
The thrower function. | |
Private Attributes | |
shared_ptr< void > | ptr_ |
void(AnyPtr::* | thr_ )() const |
A smart pointer to any type.
Reference:
[1] Neri, C, "Twisting the RTTI System for Safe Dynamic Casts of void* in C++", Dr.Dobb's Journal, April 05, 2011. http://drdobbs.com/cpp/229401004
AnyPtr | ( | T * | ptr | ) | [explicit] |
Constructor taking a generic (raw) pointer type.
T | : (template parameter) Defines the input pointer type. | |
ptr | : The input pointer. |
AnyPtr | ( | shared_ptr< T > | ptr | ) | [explicit] |
Constructor taking a shared_ptr<T>.
T | : (template parameter) Defines the input pointer type. | |
ptr | : The input pointer. |
operator shared_ptr< T > | ( | ) | const |
Automatic cast to shared_ptr<T>.
T | : (template parameter) Defines the output type. |
shared_ptr<T>.
Otherwise, it returns a null shared_ptr<T>.
operator bool | ( | ) | const |
Automatic conversion to bool
.
true
if the pointer is non NULL and false
otherwise. void thrower | ( | ) | const [private] |
The thrower function.