std::experi...al::weak_ptr(3)
π NAME π
std::experimental::weak_ptr β std::experimental::weak_ptr (yes bestie, that's the whole name section, the manpage said it twice and honestly? iconic of it) β¨
β¨ SYNOPSIS β¨
okay so first things first, she lives here:
Defined in header <experimental/memory>
template< class T > class weak_ptr; (library fundamentals TS)
And what is she? Okay so std::experimental::weak_ptr is a modified version of std::weak_ptr β like, the glow-up edition π
β and she does two things the original doesn't:
- she interoperates with
std::experimental::shared_ptrπ«Ά - she has support for arrays π
That's it, that's the whole pitch, no cap. π
π¦ MEMBER TYPES π¦
One (1) member type, and she ate:
element_typeβ defined asstd::remove_extent_t<T>β
πΈ MEMBER FUNCTIONS πΈ
- constructor β constructs new
weak_ptr(public member function) π§
π MEMBERS AND NON-MEMBERS IDENTICAL TO std::weak_ptr π
Everything under this heading is the same energy as std::weak_ptr β except the parts below have a little twist:
Heads up bestie: the following member functions work withstd::experimental::shared_ptrinstead ofstd::shared_ptr, and withstd::experimental::weak_ptrinstead ofstd::weak_ptr. The behavior is otherwise identical. So don't overthink it π
π Member functions π
- destructor β destroys a
weak_ptr(public member function ofstd::weak_ptr<T>) operator=β assigns theweak_ptr(public member function ofstd::weak_ptr<T>)
π₯ Modifiers π₯
resetβ releases the ownership of the managed object (public member function ofstd::weak_ptr<T>)swapβ swaps the managed objects (public member function ofstd::weak_ptr<T>)
β Observers β
use_countβ returns the number ofshared_ptrobjects that manage the object (public member function ofstd::weak_ptr<T>)expiredβ checks whether the referenced object was already deleted (public member function ofstd::weak_ptr<T>)lockβ creates ashared_ptrthat manages the referenced object (public member function ofstd::weak_ptr<T>)owner_beforeβ provides owner-based ordering of weak pointers (public member function ofstd::weak_ptr<T>)
π Non-member functions π
Plot twist: this non-member function is declared in the std::experimental namespace, and works with std::experimental::weak_ptr rather than std::weak_ptr β but otherwise she behaves identically to the corresponding C++14 function. Same girl, different namespace π
std::swap(std::weak_ptr)β specializes thestd::swapalgorithm (C++11) (function template)
π EXAMPLE π
This section is incomplete.
Reason: no example π (ngl we're all waiting on this one)
π CATEGORIES π
- Noindexed pages
- Todo no example
Okay that's the whole page, bestie β you understood it, I'm so proud of you, mwah π«Άπ
Catch her at http://cppreference.com, dated 2024.06.10, filed under std::experi...al::weak_ptr(3) in the C++ Standard Library. Slay, go read some docs, periodt. β¨π
π¦ 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