std::experi...observer_ptr(3)
π
std::experi...observer_ptr(3) π
okay bestie, welcome to the C++ Standard Library manual page for std::experimental::observer_ptr β the original header spells it βLibaryβ and honestly? iconic typo energy π. The full manual name is std::experi...observer_ptr(3), so if you see that truncated little gremlin, it's this page. β¨
β¨ 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. She's just watching, not parenting. π
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. So she's literally saying βhi, I'm an observer, read me and move onβ β main character energy fr fr. π
Specializations of observer_ptr satisfy the requirements of CopyConstructible and CopyAssignable. slay. β¨
π¦ Type requirements π¦
Wshall not be a reference type, but may be an incomplete type.
π Member types π
- Member type:
element_typeβ Definition:W, the type of the object watched by thisobserver_ptr
π Member functions π
constructorβ constructs a newobserver_ptr(public member function)destructorβ destructs anobserver_ptr(implicitly declared) (public member function)operator=β implicitly declared copy and move assignment operators that assign the stored pointer (implicitly declared) (public member function)
π₯ Modifiers π₯
releaseβ returns a pointer to the watched object and stops watching the object (public member function)resetβ replaces the watched object (public member function)swapβ swaps the watched objects (public member function)
π Observers π
getβ returns a pointer to the watched object (public member function)operator boolβ checks if there is an associated watched object (public member function)operator*β dereferences pointer to the watched objectoperator->β (public member function)
π Conversions π
operator element_type*β explicit conversion function to the stored pointer (public member function)
π Non-member functions π
make_observerβ creates anobserver_ptrthat watches an object (function template)operator==,operator!=,operator<,operator<=,operator>,operator>=β compares to anotherobserver_ptror withnullptr(function template)std::experimental::swap(std::experimental::observer_ptr)β specializes theswapalgorithm (function template)
π§ Helper classes π§
std::hash<std::experimental::observer_ptr>β hash support forobserver_ptr(class template specialization)
π Example π
This section is incomplete
Reason: no example
π Category π
- Todo no example
okay bestie, that's the whole page π source: http://cppreference.com, version/date: 2024.06.10, and the footer title is std::experi...observer_ptr(3). mwah πβ¨
π¦ where this page comes from
- nixpkgs unstable: stdman 2024.07.05
- opensuse-leap 16.0: stdman 2024.07.05-bp160.1.9 Β· MIT
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms