std::experi...::shared_ptr(3)
okay so bestie, welcome to std::experi...::shared_ptr(3) from the C++ Standard Libary β yes, thatβs the manual name, typo and all, and weβre obsessed π. This is the std::experimental::shared_ptr moment: same energy as std::shared_ptr, but with array support added. Letβs get into it β¨
πΈ NAME πΈ
std::experimental::shared_ptr β std::experimental::shared_ptr. thatβs literally the whole NAME line, bestie π
β¨ Synopsis β¨
Defined in header <experimental/memory> π
template< class T > class shared_ptr; (library fundamentals TS)
std::experimental::shared_ptr is a modified version of std::shared_ptr that adds support for arrays. π«Ά
𧬠Member types π§¬
element_typeβstd::remove_extent_t<T>π
π Member functions π
constructorβ constructs newshared_ptr(public member function) β¨
π Observers π
getβ returns the stored pointer (public member function) πoperator*β dereferences the stored pointer βoperator->β public member function (the page gives it the(public member function)tag here without a separate one-line description, bestie) πoperator[]β provides index access to the array (public member function) π
π Non-member functions π
static_pointer_cast,dynamic_pointer_cast,const_pointer_cast,reinterpret_pointer_castβ these function templates applystatic_cast,dynamic_cast,const_cast, orreinterpret_castto the stored pointer β¨
π Helper classes π
std::hash<std::experimental::shared_ptr>β hash support forstd::experimental::shared_ptr(class template specialization) π§
π«Ά Members and non-members identical to std::shared_ptr π«Ά
πΈ Member functions πΈ
The following member functions work with std::experimental::shared_ptr instead of std::shared_ptr and std::experimental::weak_ptr instead of std::weak_ptr. The behavior is otherwise identical. π
destructorβ destructs the owned object if no moreshared_ptrslink to it (public member function ofstd::shared_ptr<T>) πoperator=β assigns theshared_ptr(public member function ofstd::shared_ptr<T>) π«Ά
π οΈ Modifiers π οΈ
resetβ replaces the managed object (public member function ofstd::shared_ptr<T>) πswapβ swaps the managed objects (public member function ofstd::shared_ptr<T>) π
π Observers π
use_countβ returns the number ofshared_ptrobjects referring to the same managed object (public member function ofstd::shared_ptr<T>) π’uniqueβ(until C++20)checks whether the managed object is managed only by the currentshared_ptrobject (public member function ofstd::shared_ptr<T>) π¦operator boolβ checks if the stored pointer is not null (public member function ofstd::shared_ptr<T>) βowner_beforeβ provides owner-based ordering of shared pointers (public member function ofstd::shared_ptr<T>) π
π Non-member functions π
These non-member functions are declared in the std::experimental namespace, and work with std::experimental::shared_ptr rather than std::shared_ptr, but otherwise they behave identically to the corresponding C++14 function. π«
make_shared,make_shared_for_overwrite(C++20)β creates a shared pointer that manages a new object (function template) π±allocate_shared,allocate_shared_for_overwrite(C++20)β creates a shared pointer that manages a new object allocated using an allocator (function template) π§Ίget_deleterβ returns the deleter of specified type, if owned (function template) ποΈoperator==,operator!=,operator<,operator<=,operator>,operator>=β compares with anothershared_ptror withnullptr(function template) βοΈ
Version tags in this group: (removed in C++20), (removed in C++20), (removed in C++20), (removed in C++20), (removed in C++20) β yes, five of them, exactly as listed π
operator<=>β(C++20)function template πoperator<<(std::shared_ptr)β outputs the value of the stored pointer to an output stream (function template) π¨οΈstd::swap(std::shared_ptr)β specializes thestd::swapalgorithm(C++11)(function template) π
These are function templates that specialize atomic operations for std::shared_ptr, and the page tags them (deprecated in C++20), (removed in C++26): βοΈ
std::atomic_is_lock_free(std::shared_ptr)std::atomic_load(std::shared_ptr)std::atomic_load_explicit(std::shared_ptr)std::atomic_store(std::shared_ptr)std::atomic_store_explicit(std::shared_ptr)std::atomic_exchange(std::shared_ptr)std::atomic_exchange_explicit(std::shared_ptr)std::atomic_compare_exchange_weak(std::shared_ptr)std::atomic_compare_exchange_strong(std::shared_ptr)std::atomic_compare_exchange_weak_explicit(std::shared_ptr)std::atomic_compare_exchange_strong_explicit(std::shared_ptr)
π§ Helper class templates π§
These class templates are declared in the std::experimental namespace, and work with std::experimental::shared_ptr and std::experimental::weak_ptr rather than std::shared_ptr and std::weak_ptr, but otherwise behave identically to the corresponding C++14 class template. π
owner_less(C++11)β provides mixed-type owner-based ordering of shared and weak pointers (class template) πenable_shared_from_this(C++11)β allows an object to create ashared_ptrreferring to itself (class template) πͺ
π§ͺ Example π§ͺ
This section is incomplete Reason: no example
no example yet, bestie β weβre leaving that one on read π
π·οΈ Categories: π·οΈ
Noindexed pagesTodo no example
mwah π source/version line: http://cppreference.com; date: 2024.06.10; page: std::experi...::shared_ptr(3). thatβs the whole page, bestie β go be iconic with your arrays β¨
π¦ 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