Ptr stores a pointer and optionally takes ownership of the value.
More...
#include <Ptr.hpp>
|
| Ptr () |
| Default constructor yielding a NULL-pointer.
|
|
| Ptr (T *ptr) |
| Do not take ownership of ptr. More...
|
|
| Ptr (cpp_shared_ptr ptr) |
| Take ownership of ptr. More...
|
|
| ~Ptr () |
| destructor
|
|
template<class S > |
Ptr< S > | cast () |
| Cast the smart pointer to a different type. More...
|
|
template<class S > |
Ptr< S > | cast () const |
| Cast the smart pointer to a different type. More...
|
|
template<class S > |
Ptr< S > | scast () |
| Cast the smart pointer statically to a different type. More...
|
|
template<class S > |
Ptr< S > | scast () const |
| Cast the smart pointer statically to a different type. More...
|
|
template<class S > |
| Ptr (Ptr< S > const &p, typename std::enable_if< std::is_base_of< T, S >::value >::type *=0) |
| Construct smart pointer from other smart pointer. More...
|
|
T * | get () const |
| The pointer stored in the object.
|
|
T & | operator* () const |
| Dereferencing operator.
|
|
T * | operator-> () const |
| Member access operator.
|
|
| operator const void * () const |
| Support for implicit conversion to bool.
|
|
Ptr< T > & | operator= (cpp_shared_ptr &ptr) |
|
template<class A > |
bool | operator== (const Ptr< A > &p) const |
| equallity operator, this only tests if the pointers to the referenced objects are the same and NOT if the smart pointers are the same. More...
|
|
bool | operator== (void *p) const |
| Tests if the smart pointer points to the same instance as p.
|
|
bool | operator!= (void *p) const |
| Tests if the smart pointer points to different from the instance of p.
|
|
bool | isShared () const |
| check if this Ptr has shared ownership or none ownership More...
|
|
bool | isNull () const |
| checks if the pointer is null More...
|
|
cpp_shared_ptr | getCppSharedPtr () const |
| Returns the shared pointer used internally.
|
|
| operator cpp_shared_ptr () const |
| Implicitly convert to std::shared_ptr type. More...
|
|
shared_ptr | getSharedPtr () const |
| Returns the shared pointer used internally.
|
|
Ptr< const T > | cptr () const |
| Get const Pointer. More...
|
|
|
(Note that these are not member functions.)
|
template<class T > |
Ptr< T > | ownedPtr (T *ptr) |
| A Ptr that takes ownership over a raw pointer ptr.
|
|
template<class T > |
std::vector< std::shared_ptr< T > > | toStd (const std::vector< Ptr< T >> &ptrs) |
| Convert a vector of Ptr to a vector of std::shared_ptr. More...
|
|
template<class T > |
std::vector< Ptr< T > > | fromStd (const std::vector< std::shared_ptr< T >> &ptrs) |
| Convert a vector of std::shared_ptr to a vector of Ptr. More...
|
|
template<class T>
class rw::core::Ptr< T >
Ptr stores a pointer and optionally takes ownership of the value.
◆ Ptr() [1/3]
Do not take ownership of ptr.
ptr can be null.
The constructor is implicit on purpose.
◆ Ptr() [2/3]
Take ownership of ptr.
ptr can be null.
The constructor is implicit on purpose.
◆ Ptr() [3/3]
Ptr |
( |
Ptr< S > const & |
p, |
|
|
typename std::enable_if< std::is_base_of< T, S >::value >::type * |
= 0 |
|
) |
| |
|
inline |
Construct smart pointer from other smart pointer.
- Parameters
-
p | the other (compatible) smart pointer. |
◆ cast() [1/2]
Cast the smart pointer to a different type.
- Returns
- smart pointer that can be null if cast was not possible.
◆ cast() [2/2]
Cast the smart pointer to a different type.
- Returns
- smart pointer that can be null if cast was not possible.
◆ cptr()
Ptr<const T> cptr |
( |
| ) |
const |
|
inline |
Get const Pointer.
- Returns
- a copy in the form of Ptr<const T>;
◆ isNull()
checks if the pointer is null
- Returns
- Returns true if the pointer is null
◆ isShared()
check if this Ptr has shared ownership or none ownership
- Returns
- true if Ptr has shared ownership, false if it has no ownership.
◆ operator cpp_shared_ptr()
Implicitly convert to std::shared_ptr type.
- Returns
- std::shared_ptr
◆ operator==()
bool operator== |
( |
const Ptr< A > & |
p | ) |
const |
|
inline |
equallity operator, this only tests if the pointers to the referenced objects are the same and NOT if the smart pointers are the same.
- Parameters
-
p | [in] smart pointer to compare with |
- Returns
- true if the referenced objects are the same
◆ scast() [1/2]
Cast the smart pointer statically to a different type.
This is more efficient if it is already known that the object is of a certain type. If this is not known, please use the more safe cast() instead.
- Returns
- smart pointer that can be null if cast was not possible.
◆ scast() [2/2]
Cast the smart pointer statically to a different type.
This is more efficient if it is already known that the object is of a certain type. If this is not known, please use the more safe cast() instead.
- Returns
- smart pointer that can be null if cast was not possible.
◆ fromStd()
std::vector< Ptr< T > > fromStd |
( |
const std::vector< std::shared_ptr< T >> & |
ptrs | ) |
|
|
related |
Convert a vector of std::shared_ptr to a vector of Ptr.
- Parameters
-
ptrs | [in] vector of std::shared_ptr. |
- Returns
- a vector of Ptr with same size.
◆ toStd()
std::vector< std::shared_ptr< T > > toStd |
( |
const std::vector< Ptr< T >> & |
ptrs | ) |
|
|
related |
Convert a vector of Ptr to a vector of std::shared_ptr.
- Parameters
-
- Returns
- a vector of std::shared_ptr with same size.
The documentation for this class was generated from the following files: