Wt  4.0.2
Public Member Functions | List of all members
Wt::Core::observing_ptr< T > Class Template Reference

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...
 

Detailed Description

template<typename T>
class Wt::Core::observing_ptr< T >

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.

See also
observable

Constructor & Destructor Documentation

template<typename T>
Wt::Core::observing_ptr< T >::observing_ptr ( T *  t = nullptr)
noexcept

Constructor.

See also
reset()

Member Function Documentation

template<typename T >
T * Wt::Core::observing_ptr< T >::get ( ) const
noexcept

Returns the pointer value.

Returns the value set to it, or null if the object was deleted.

See also
reset()
template<typename T >
bool Wt::Core::observing_ptr< T >::observedDeleted ( ) const
noexcept

Returns whether the observed object has been deleted.

Returns if the pointed object has been deleted.

template<typename T >
Wt::Core::observing_ptr< T >::operator bool ( ) const
noexcept

Returns whether the pointer is still valid.

Returns if the pointer does not point to null and the pointed object isn't deleted.

template<typename T >
T & Wt::Core::observing_ptr< T >::operator* ( ) const

Dereferences the pointer.

This throws a std::runtime_error if the pointer cannot be dereferenced.

template<typename T >
T * Wt::Core::observing_ptr< T >::operator-> ( ) const

Dereferences the pointer.

This throws a std::runtime_error if the pointer cannot be dereferenced.


Generated on Fri Nov 24 2017 for the C++ Web Toolkit (Wt) by doxygen 1.8.11