A smart pointer for observing another pointer. This means that it preforms no memory management on the lifetime of the observed pointer. This functionally acts as a marker for other developers that this pointer's does not need to be managed nor can it be accidentally deleted. More...
#include <ObserverPtr.hpp>
Public Types | |
using | element_type = ObservedType |
The type the smart pointer is observing. | |
using | pointer = ObservedType* |
The pointer type the smart pointer is observing. | |
Public Member Functions | |
ObserverPtr (const ObserverPtr &)=default | |
ObserverPtr (const std::unique_ptr< ObservedType > &observe) | |
Full initialisation constructor for observing a standard unique pointer. | |
ObserverPtr (const UniqueQtPtr< ObservedType > &observe) | |
Full initialisation constructor for observing a Qt unique pointer. | |
ObserverPtr (ObservedType *const observe=nullptr) | |
Full initialisation constructor for observing a naked pointer. | |
ObserverPtr (ObserverPtr &&)=default | |
~ObserverPtr ()=default | |
ObservedType * | get () const noexcept |
An accessor to the underlying pointer being observed. | |
operator bool () const noexcept | |
Determines if this object is observing a pointer. | |
void | operator delete (void *)=delete |
operator ObservedType * () const noexcept | |
Conversion operator to the underlying pointer being observed. | |
bool | operator!= (const ObservedType *observed) const |
Inequality operator for testing if this object points to another specified pointer. | |
bool | operator!= (const ObserverPtr &other) const |
Inequality operator for testing if this object points to another specified pointer. | |
bool | operator!= (const std::nullptr_t) const |
Inequality operator for testing if this object points to null. | |
ObservedType & | operator* () |
Dereference pointer to the observed pointer. The behaviour is undefined if the observed pointer is null. | |
ObservedType & | operator* () const |
Dereference pointer to the observed pointer. The behaviour is undefined if the observed pointer is null. | |
ObservedType * | operator-> () |
Dereference pointer to the observed pointer. The behaviour is undefined if the observed pointer is null. | |
ObservedType * | operator-> () const |
Dereference pointer to the observed pointer. The behaviour is undefined if the observed pointer is null. | |
bool | operator< (const ObservedType *observed) const |
Less-than operator for testing if the address observed by this object appears before another specified naked pointer's address. | |
bool | operator< (const ObserverPtr &other) const |
Less-than operator for testing if the address observed by this object appears before another specified pointer's address. | |
ObserverPtr & | operator= (const ObserverPtr &)=default |
ObserverPtr & | operator= (const std::nullptr_t) |
An assignment operator for setting the object to be null. | |
ObserverPtr & | operator= (ObservedType *const observe) |
An assignment operator for setting the object to observe another pointer. | |
ObserverPtr & | operator= (ObserverPtr &&)=default |
bool | operator== (const ObservedType *observed) const |
Equality operator for testing if this object points to another specified pointer. | |
bool | operator== (const ObserverPtr &other) const |
Equality operator for testing if this object points to another specified pointer. | |
bool | operator== (const std::nullptr_t) const |
Equality operator for testing if this object points to null. | |
A smart pointer for observing another pointer. This means that it preforms no memory management on the lifetime of the observed pointer. This functionally acts as a marker for other developers that this pointer's does not need to be managed nor can it be accidentally deleted.
@tparm ObservedType The type the smart pointer is observing.
using drn::foundation::ObserverPtr< ObservedType >::element_type = ObservedType |
The type the smart pointer is observing.
using drn::foundation::ObserverPtr< ObservedType >::pointer = ObservedType* |
The pointer type the smart pointer is observing.
drn::foundation::ObserverPtr< ObservedType >::ObserverPtr | ( | ObservedType *const | observe = nullptr | ) |
Full initialisation constructor for observing a naked pointer.
observe | The pointer that is to be observed. |
drn::foundation::ObserverPtr< ObservedType >::ObserverPtr | ( | const std::unique_ptr< ObservedType > & | observe | ) |
Full initialisation constructor for observing a standard unique pointer.
observe | The pointer that is to be observed. |
drn::foundation::ObserverPtr< ObservedType >::ObserverPtr | ( | const UniqueQtPtr< ObservedType > & | observe | ) |
Full initialisation constructor for observing a Qt unique pointer.
observe | The pointer that is to be observed. |
|
default |
|
default |
|
default |
|
noexcept |
An accessor to the underlying pointer being observed.
|
explicitnoexcept |
Determines if this object is observing a pointer.
|
delete |
|
explicitnoexcept |
Conversion operator to the underlying pointer being observed.
bool drn::foundation::ObserverPtr< ObservedType >::operator!= | ( | const ObservedType * | observed | ) | const |
Inequality operator for testing if this object points to another specified pointer.
observed | The other observed pointer to compare against. |
bool drn::foundation::ObserverPtr< ObservedType >::operator!= | ( | const ObserverPtr< ObservedType > & | other | ) | const |
Inequality operator for testing if this object points to another specified pointer.
other | The other observed pointer to compare against. |
bool drn::foundation::ObserverPtr< ObservedType >::operator!= | ( | const std::nullptr_t | ) | const |
Inequality operator for testing if this object points to null.
ObservedType & drn::foundation::ObserverPtr< ObservedType >::operator* | ( | ) |
Dereference pointer to the observed pointer. The behaviour is undefined if the observed pointer is null.
ObservedType & drn::foundation::ObserverPtr< ObservedType >::operator* | ( | ) | const |
Dereference pointer to the observed pointer. The behaviour is undefined if the observed pointer is null.
ObservedType * drn::foundation::ObserverPtr< ObservedType >::operator-> | ( | ) |
Dereference pointer to the observed pointer. The behaviour is undefined if the observed pointer is null.
ObservedType * drn::foundation::ObserverPtr< ObservedType >::operator-> | ( | ) | const |
Dereference pointer to the observed pointer. The behaviour is undefined if the observed pointer is null.
bool drn::foundation::ObserverPtr< ObservedType >::operator< | ( | const ObservedType * | observed | ) | const |
Less-than operator for testing if the address observed by this object appears before another specified naked pointer's address.
observed | The observed pointer to compare against. |
bool drn::foundation::ObserverPtr< ObservedType >::operator< | ( | const ObserverPtr< ObservedType > & | other | ) | const |
Less-than operator for testing if the address observed by this object appears before another specified pointer's address.
other | The observed pointer to compare against. |
|
default |
ObserverPtr & drn::foundation::ObserverPtr< ObservedType >::operator= | ( | const std::nullptr_t | ) |
An assignment operator for setting the object to be null.
ObserverPtr & drn::foundation::ObserverPtr< ObservedType >::operator= | ( | ObservedType *const | observe | ) |
An assignment operator for setting the object to observe another pointer.
observe | The pointer that is to be observed. |
|
default |
bool drn::foundation::ObserverPtr< ObservedType >::operator== | ( | const ObservedType * | observed | ) | const |
Equality operator for testing if this object points to another specified pointer.
observed | The other observed pointer to compare against. |
bool drn::foundation::ObserverPtr< ObservedType >::operator== | ( | const ObserverPtr< ObservedType > & | other | ) | const |
Equality operator for testing if this object points to another specified pointer.
other | The other observed pointer to compare against. |
bool drn::foundation::ObserverPtr< ObservedType >::operator== | ( | const std::nullptr_t | ) | const |
Equality operator for testing if this object points to null.