Wt
4.11.1
|
A safe smart pointer for an observable. More...
Public Member Functions | |
observing_ptr (T *t=nullptr) noexcept | |
Constructor. More... | |
observing_ptr (const observing_ptr< T > &other) noexcept | |
Copy constructor. | |
observing_ptr (observing_ptr< T > &&other) noexcept | |
Move constructor. | |
observing_ptr< T > & | operator= (const observing_ptr< T > &other) noexcept |
Copy assignment operator. | |
observing_ptr< T > & | operator= (observing_ptr< T > &&other) noexcept |
Move assignment operator. | |
template<typename S , typename = typename std::enable_if<std::is_convertible<S*, T*>::value>::type> | |
observing_ptr (const observing_ptr< S > &other) noexcept | |
Copy constructor with type conversion. | |
template<typename S , typename = typename std::enable_if<std::is_convertible<S*, T*>::value>::type> | |
observing_ptr (observing_ptr< S > &&other) noexcept | |
Move constructor with type conversion. | |
template<typename S , typename = typename std::enable_if<std::is_convertible<S*, T*>::value>::type> | |
observing_ptr< T > & | operator= (const observing_ptr< S > &other) noexcept |
Copy assignment operator with type conversion. | |
template<typename S , typename = typename std::enable_if<std::is_convertible<S*, T*>::value>::type> | |
observing_ptr< T > & | operator= (observing_ptr< S > &&other) noexcept |
Move assignment operator with type conversion. | |
T * | get () const noexcept |
Returns the pointer value. More... | |
void | reset (T *v=nullptr) noexcept |
Resets the value. | |
T * | operator-> () const |
Dereferences the pointer. More... | |
T & | operator* () const |
Dereferences the pointer. More... | |
operator bool () const noexcept | |
Returns whether the pointer is still valid. More... | |
bool | observedDeleted () const noexcept |
Returns whether the observed object has been deleted. More... | |
A safe smart pointer for an observable.
This smart pointer can point only to objects that are observable. They are safe in the sense that they are aware of the life-time of the observed object, and thus cannot dangle. When dereferencing a pointer to an already destroyed object, an exception is thrown.
|
noexcept |
Constructor.
|
noexcept |
Returns the pointer value.
Returns the value set to it, or null
if the object was deleted.
|
noexcept |
Returns whether the observed object has been deleted.
Returns if the pointed object has been deleted.
|
explicitnoexcept |
Returns whether the pointer is still valid.
Returns if the pointer does not point to null
and the pointed object isn't deleted.
T & Wt::Core::observing_ptr< T >::operator* |
Dereferences the pointer.
This throws a std::runtime_error if the pointer cannot be dereferenced.
T * Wt::Core::observing_ptr< T >::operator-> |
Dereferences the pointer.
This throws a std::runtime_error if the pointer cannot be dereferenced.