std::experimental::observer_ptr (3) - Linux Man Pages

std::experimental::observer_ptr: std::experimental::observer_ptr

NAME

std::experimental::observer_ptr - std::experimental::observer_ptr

Synopsis


Defined in header <experimental/memory>
template< class W > (library fundamentals TS v2)
class observer_ptr;


std::experimental::observer_ptr is a non-owning pointer, or observer. The observer stores a pointer to a second object, known as the watched object. An observer_ptr may also have no watched object.
An observer is not responsible in any way for the watched object; there is no inherent relationship between an observer and the object it watches.
It is intended as a near drop-in replacement for raw pointer types, with the advantage that, as a vocabulary type, it indicates its intended use without need for detailed analysis by code readers.
Specializations of observer_ptr satisfy the requirements of CopyConstructible and CopyAssignable.

Type requirements


-
W shall not be a reference type, but may be an incomplete type.

Member types


Member type Definition
element_type W, the type of the object watched by this observer_ptr

Member functions


                       constructs a new observer_ptr
constructor (public member function)


destructor destructs an observer_ptr
                       (public member function)
(implicitly declared)


operator= implicitly declared copy and move assignment operators that assign the stored pointer
                       (public member function)
(implicitly declared)

Modifiers


                       returns a pointer to the watched object and stops watching the object
release (public member function)
                       replaces the watched object
reset (public member function)
                       swaps the watched objects
swap (public member function)

Observers


                       returns a pointer to the watched object
get (public member function)
                       checks if there is an associated watched object
operator_bool (public member function)
                       dereferences pointer to the watched object
operator* (public member function)
operator->

Conversions


                       explicit conversion function to the stored pointer
operator_element_type* (public member function)

Non-member functions


                                                         creates a observer_ptr that watches an object
make_observer (function template)


operator==
operator!= compares to another observer_ptr or with nullptr
operator< (function template)
operator<=
operator>
operator>=
                                                         specializes the swap algorithm
std::experimental::swap(std::experimental::observer_ptr) (function template)

Helper classes


                                           hash support for observer_ptr
std::hash<std::experimental::observer_ptr> (class template specialization)

Example


 This section is incomplete
 Reason: no example