Movatterモバイル変換


[0]ホーム

URL:


cppreference.com
Namespaces
Variants
    Actions

      Standard library header <memory>

      From cppreference.com
      <cpp‎ |header
       
       
      Standard library headers
       

      This header is part of thedynamic memory management library.

      Contents

      Includes

      (C++20)
      Three-way comparison operator support[edit]

      Classes

      Pointer traits
      provides information about pointer-like types
      (class template)[edit]
      Garbage collector support
      (C++11)(removed in C++23)
      lists pointer safety models
      (enum)[edit]
      Allocators
      the default allocator
      (class template)[edit]
      provides information about allocator types
      (class template)[edit]
      records the address and the actual size of storage allocated byallocate_at_least
      (class template)[edit]
      checks if the specified type supports uses-allocator construction
      (class template)[edit]
      Uninitialized storage
      (deprecated in C++17)(removed in C++20)
      an iterator that allows standard algorithms to store results in uninitialized memory
      (class template)[edit]
      Smart pointers
      (C++11)
      smart pointer with unique object ownership semantics
      (class template)[edit]
      (C++11)
      smart pointer with shared object ownership semantics
      (class template)[edit]
      (C++11)
      weak reference to an object managed bystd::shared_ptr
      (class template)[edit]
      (deprecated in C++11)(removed in C++17)
      smart pointer with strict object ownership semantics
      (class template)[edit]
      Smart pointer adaptors
      (C++23)
      interoperates with foreign pointer setters and resets a smart pointer on destruction
      (class template)[edit]
      interoperates with foreign pointer setters, obtains the initial pointer value from a smart pointer, and resets it on destruction
      (class template)[edit]
      Types for composite class design
      (C++26)
      a wrapper containing dynamically-allocated object with value-like semantics
      (class template)[edit]
      a polymorphic wrapper containing dynamically-allocated object with value-like semantics
      (class template)[edit]
      Helper classes
      atomic shared pointer
      (class template specialization)[edit]
      atomic weak pointer
      (class template specialization)[edit]
      (C++11)
      provides mixed-type owner-based ordering of shared and weak pointers
      (class template)[edit]
      (C++26)
      provides owner-based hashing for shared and weak pointers
      (class)[edit]
      provides mixed-type owner-based equal comparisons of shared and weak pointers
      (class)[edit]
      allows an object to create ashared_ptr referring to itself
      (class template)[edit]
      exception thrown when accessing aweak_ptr which refers to already destroyed object
      (class)[edit]
      default deleter forunique_ptr
      (class template)[edit]
      hash support forstd::unique_ptr
      (class template specialization)[edit]
      hash support forstd::shared_ptr
      (class template specialization)[edit]
      hash support forstd::indirect
      (class template specialization)[edit]
      Forward declarations
      Defined in header<functional>
      (C++11)
      hash function object
      (class template)[edit]
      Defined in header<atomic>
      (C++11)
      atomic class template and specializations for bool, integral, floating-point,(since C++20) and pointer types
      (class template)[edit]

      Tags

      a tag used to select allocator-aware constructors
      (tag)[edit]

      Functions

      Uses-allocator construction
      prepares the argument list matching the flavor of uses-allocator construction required by the given type
      (function template)[edit]
      creates an object of the given type by means of uses-allocator construction
      (function template)[edit]
      creates an object of the given type at specified memory location by means of uses-allocator construction
      (function template)[edit]
      Miscellaneous
      (C++20)
      obtains a raw pointer from a pointer-like type
      (function template)[edit]
      (C++11)
      obtains actual address of an object, even if the& operator is overloaded
      (function template)[edit]
      (C++11)
      aligns a pointer in a buffer
      (function)[edit]
      informs the compiler that a pointer is aligned
      (function template)[edit]
      checks whether the pointer points to an object whose alignment has at least the given value
      (function template)[edit]
      Explicit lifetime management
      implicitly creates objects in given storage with the object representation reused
      (function template)[edit]
      Garbage collector support
      (C++11)(removed in C++23)
      declares that an object can not be recycled
      (function)[edit]
      (C++11)(removed in C++23)
      declares that an object can be recycled
      (function template)[edit]
      (C++11)(removed in C++23)
      declares that a memory area does not contain traceable pointers
      (function)[edit]
      (C++11)(removed in C++23)
      cancels the effect ofstd::declare_no_pointers
      (function)[edit]
      (C++11)(removed in C++23)
      returns the current pointer safety model
      (function)[edit]
      Uninitialized storage
      copies a range of objects to an uninitialized area of memory
      (function template)[edit]
      copies a number of objects to an uninitialized area of memory
      (function template)[edit]
      copies an object to an uninitialized area of memory, defined by a range
      (function template)[edit]
      copies an object to an uninitialized area of memory, defined by a start and a count
      (function template)[edit]
      moves a range of objects to an uninitialized area of memory
      (function template)[edit]
      moves a number of objects to an uninitialized area of memory
      (function template)[edit]
      constructs objects bydefault-initialization in an uninitialized area of memory, defined by a range
      (function template)[edit]
      constructs objects bydefault-initialization in an uninitialized area of memory, defined by a start and a count
      (function template)[edit]
      constructs objects byvalue-initialization in an uninitialized area of memory, defined by a range
      (function template)[edit]
      constructs objects byvalue-initialization in an uninitialized area of memory, defined by a start and a count
      (function template)[edit]
      creates an object at a given address
      (function template)[edit]
      (C++17)
      destroys an object at a given address
      (function template)[edit]
      (C++17)
      destroys a range of objects
      (function template)[edit]
      (C++17)
      destroys a number of objects in a range
      (function template)[edit]
      (deprecated in C++17)(removed in C++20)
      obtains uninitialized storage
      (function template)[edit]
      (deprecated in C++17)(removed in C++20)
      frees uninitialized storage
      (function template)[edit]
      Smart pointer non-member operations
      creates a unique pointer that manages a new object
      (function template)[edit]
      compares to anotherunique_ptr or withnullptr
      (function template)[edit]
      creates a shared pointer that manages a new object
      (function template)[edit]
      creates a shared pointer that manages a new object allocated using an allocator
      (function template)[edit]
      appliesstatic_cast,dynamic_cast,const_cast, orreinterpret_cast to the stored pointer
      (function template)[edit]
      returns the deleter of specified type, if owned
      (function template)[edit]
      (removed in C++20)(removed in C++20)(removed in C++20)(removed in C++20)(removed in C++20)(C++20)
      compares with anothershared_ptr or withnullptr
      (function template)[edit]
      outputs the value of the stored pointer to an output stream
      (function template)[edit]
      outputs the value of the managed pointer to an output stream
      (function template)[edit]
      specializes thestd::swap algorithm
      (function template)[edit]
      specializes thestd::swap algorithm
      (function template)[edit]
      specializes thestd::swap algorithm
      (function template)[edit]
      Smart pointer adaptor creation
      (C++23)
      creates anout_ptr_t with an associated smart pointer and resetting arguments
      (function template)[edit]
      (C++23)
      creates aninout_ptr_t with an associated smart pointer and resetting arguments
      (function template)[edit]
      specializes atomic operations forstd::shared_ptr
      (function template)[edit]

      Function-like entities

      Defined in namespacestd::ranges
      Uninitialized storage
      copies a range of objects to an uninitialized area of memory
      (algorithm function object)[edit]
      copies a number of objects to an uninitialized area of memory
      (algorithm function object)[edit]
      copies an object to an uninitialized area of memory, defined by a range
      (algorithm function object)[edit]
      copies an object to an uninitialized area of memory, defined by a start and a count
      (algorithm function object)[edit]
      moves a range of objects to an uninitialized area of memory
      (algorithm function object)[edit]
      moves a number of objects to an uninitialized area of memory
      (algorithm function object)[edit]
      constructs objects bydefault-initialization in an uninitialized area of memory, defined by a range
      (algorithm function object)[edit]
      constructs objects bydefault-initialization in an uninitialized area of memory, defined by a start and count
      (algorithm function object)[edit]
      constructs objects byvalue-initialization in an uninitialized area of memory, defined by a range
      (algorithm function object)[edit]
      constructs objects byvalue-initialization in an uninitialized area of memory, defined by a start and a count
      (algorithm function object)[edit]
      creates an object at a given address
      (algorithm function object)[edit]
      destroys an object at a given address
      (algorithm function object)[edit]
      destroys a range of objects
      (algorithm function object)[edit]
      destroys a number of objects in a range
      (algorithm function object)[edit]

      [edit]Synopsis

      #include <compare> namespace std{// pointer Traitstemplate<class Ptr>struct pointer_traits;// freestandingtemplate<class T>struct pointer_traits<T*>;// freestanding // pointer conversiontemplate<class T>constexpr T* to_address(T* p)noexcept;// freestandingtemplate<class Ptr>constexprauto to_address(const Ptr& p)noexcept;// freestanding // pointer alignmentvoid* align(size_t alignment, size_t size,void*& ptr, size_t& space);// freestandingtemplate<size_t N,class T>constexpr T* assume_aligned(T* ptr);// freestandingtemplate<size_t Alignment,class T>bool is_sufficiently_aligned(T* ptr); // explicit lifetime managementtemplate<class T>  T* start_lifetime_as(void* p)noexcept;// freestandingtemplate<class T>const T* start_lifetime_as(constvoid* p)noexcept;// freestandingtemplate<class T>volatile T* start_lifetime_as(volatilevoid* p)noexcept;// freestandingtemplate<class T>constvolatile T* start_lifetime_as(constvolatilevoid* p)noexcept;// freestandingtemplate<class T>  T* start_lifetime_as_array(void* p, size_t n)noexcept;// freestandingtemplate<class T>const T* start_lifetime_as_array(constvoid* p, size_t n)noexcept;// freestandingtemplate<class T>volatile T* start_lifetime_as_array(volatilevoid* p,                                      size_t n)noexcept;// freestandingtemplate<class T>constvolatile T* start_lifetime_as_array(constvolatilevoid* p,// freestanding                                            size_t n)noexcept;template<class T>  T* trivially_relocate(T* first, T* last, T* result);// freestandingtemplate<class T>constexpr T* relocate(T* first, T* last, T* result);// freestanding // allocator argument tagstruct allocator_arg_t{explicit allocator_arg_t()=default;};// freestandinginlineconstexpr allocator_arg_t allocator_arg{};// freestanding // uses_allocatortemplate<class T,class Alloc>struct uses_allocator;// freestanding // uses_allocatortemplate<class T,class Alloc>constexprbool uses_allocator_v= uses_allocator<T, Alloc>::value;// freestanding // uses-allocator constructiontemplate<class T,class Alloc,class...Args>constexprauto uses_allocator_construction_args(const Alloc& alloc,// freestanding                                                  Args&&...args)noexcept;template<class T,class Alloc,class Tuple1,class Tuple2>constexprauto uses_allocator_construction_args(const Alloc& alloc,// freestanding                                                  piecewise_construct_t,                                                  Tuple1&& x,                                                  Tuple2&& y)noexcept;template<class T,class Alloc>constexprauto uses_allocator_construction_args(const Alloc& alloc)noexcept;// freestandingtemplate<class T,class Alloc,class U,class V>constexprauto uses_allocator_construction_args(const Alloc& alloc,// freestanding                                                  U&& u,                                                  V&& v)noexcept;template<class T,class Alloc,class U,class V>constexprauto uses_allocator_construction_args(const Alloc& alloc,// freestanding                                                  pair<U, V>& pr)noexcept;template<class T,class Alloc,class U,class V>constexprauto uses_allocator_construction_args(const Alloc& alloc,// freestandingconst pair<U, V>& pr)noexcept;template<class T,class Alloc,class U,class V>constexprauto uses_allocator_construction_args(const Alloc& alloc,// freestanding                                                  pair<U, V>&& pr)noexcept;template<class T,class Alloc,class U,class V>constexprauto uses_allocator_construction_args(const Alloc& alloc,// freestandingconst pair<U, V>&& pr)noexcept;template<class T,class Alloc,/*pair-like*/ P>constexprauto uses_allocator_construction_args(const Alloc& alloc,// freestanding                                                  P&& p)noexcept;template<class T,class Alloc,class U>constexprauto uses_allocator_construction_args(const Alloc& alloc,// freestanding                                                  U&& u)noexcept;template<class T,class Alloc,class...Args>constexpr T make_obj_using_allocator(const Alloc& alloc,                                       Args&&...args);// freestandingtemplate<class T,class Alloc,class...Args>constexpr T* uninitialized_construct_using_allocator(T* p,// freestandingconst Alloc& alloc,                                                       Args&&...args); // allocator Traitstemplate<class Alloc>struct allocator_traits;// freestanding template<class Pointer,class SizeType= size_t>struct allocation_result{// freestanding    Pointer ptr;    SizeType count;}; // the default allocatortemplate<class T>class allocator;template<class T,class U>constexprbool operator==(const allocator<T>&,const allocator<U>&)noexcept; // addressoftemplate<class T>constexpr T* addressof(T& r)noexcept;// freestandingtemplate<class T>const T* addressof(const T&&)= delete;// freestanding // specialized algorithms// special memory conceptstemplate<class I>  conceptno-throw-input-iterator=/* see description */;// exposition-onlytemplate<class I>  conceptno-throw-forward-iterator=/* see description */;// exposition-onlytemplate<class S,class I>  concept no-throw-sentinel-for=/* see description */;// exposition-onlytemplate<class R>  conceptno-throw-input-range=/* see description */;// exposition-onlytemplate<class R>  conceptno-throw-forward-range=/* see description */;// exposition-only template<class NoThrowForwardIter>constexprvoid uninitialized_default_construct(NoThrowForwardIter first,// freestanding                                                 NoThrowForwardIter last);template<class ExecutionPolicy,class NoThrowForwardIter>void uninitialized_default_construct(ExecutionPolicy&& exec,// freestanding-deleted,                                       NoThrowForwardIter first,                                       NoThrowForwardIter last);template<class NoThrowForwardIter,class Size>constexpr NoThrowForwardIter uninitialized_default_construct_n(NoThrowForwardIter first,                                                                 Size n);// freestandingtemplate<class ExecutionPolicy,class NoThrowForwardIter,class Size>  NoThrowForwardIter uninitialized_default_construct_n(    ExecutionPolicy&& exec,// freestanding-deleted,    NoThrowForwardIter first,    Size n); namespace ranges{template<no-throw-forward-iterator I, no-throw-sentinel-for<I> S>      requires default_initializable<iter_value_t<I>>constexpr I uninitialized_default_construct(I first, S last);// freestandingtemplate<no-throw-forward-range R>      requires default_initializable<range_value_t<R>>constexpr borrowed_iterator_t<R> uninitialized_default_construct(      R&& r);// freestanding template<no-throw-forward-iterator I>      requires default_initializable<iter_value_t<I>>constexpr I uninitialized_default_construct_n(I first,// freestanding                                                  iter_difference_t<I> n);} template<class NoThrowForwardIter>constexprvoid uninitialized_value_construct(NoThrowForwardIter first,// freestanding                                               NoThrowForwardIter last);template<class ExecutionPolicy,class NoThrowForwardIter>void uninitialized_value_construct(ExecutionPolicy&& exec,// freestanding-deleted,                                     NoThrowForwardIter first,                                     NoThrowForwardIter last);template<class NoThrowForwardIter,class Size>constexpr NoThrowForwardIter uninitialized_value_construct_n(NoThrowForwardIter first,                                                               Size n);// freestandingtemplate<class ExecutionPolicy,class NoThrowForwardIter,class Size>  NoThrowForwardIter uninitialized_value_construct_n(    ExecutionPolicy&& exec,// freestanding-deleted,    NoThrowForwardIter first,    Size n); namespace ranges{template<no-throw-forward-iterator I, no-throw-sentinel-for<I> S>      requires default_initializable<iter_value_t<I>>constexpr I uninitialized_value_construct(I first, S last);// freestandingtemplate<no-throw-forward-range R>      requires default_initializable<range_value_t<R>>constexpr borrowed_iterator_t<R> uninitialized_value_construct(R&& r);// freestanding template<no-throw-forward-iterator I>      requires default_initializable<iter_value_t<I>>constexpr I uninitialized_value_construct_n(I first,// freestanding                                                iter_difference_t<I> n);} template<class InputIter,class NoThrowForwardIter>constexpr NoThrowForwardIter uninitialized_copy(InputIter first,// freestanding                                                  InputIter last,                                                  NoThrowForwardIter result);template<class ExecutionPolicy,class ForwardIter,class NoThrowForwardIter>  NoThrowForwardIter uninitialized_copy(ExecutionPolicy&& exec,// freestanding-deleted,                                        ForwardIter first,                                        ForwardIter last,                                        NoThrowForwardIter result);template<class InputIter,class Size,class NoThrowForwardIter>constexpr NoThrowForwardIter uninitialized_copy_n(InputIter first,// freestanding                                                    Size n,                                                    NoThrowForwardIter result);template<class ExecutionPolicy,class ForwardIter,class Size,class NoThrowForwardIter>  NoThrowForwardIter uninitialized_copy_n(ExecutionPolicy&& exec,// freestanding-deleted,                                          ForwardIter first,                                          Size n,                                          NoThrowForwardIter result); namespace ranges{template<class I,class O>using uninitialized_copy_result= in_out_result<I, O>;// freestandingtemplate<input_iterator I,             sentinel_for<I> S1,no-throw-forward-iterator O,             no-throw-sentinel-for<O> S2>      requires constructible_from<iter_value_t<O>, iter_reference_t<I>>constexpr uninitialized_copy_result<I, O>    uninitialized_copy(I ifirst, S1 ilast, O ofirst, S2 olast);// freestandingtemplate<input_range IR,no-throw-forward-range OR>      requires constructible_from<range_value_t<OR>, range_reference_t<IR>>constexpr uninitialized_copy_result<borrowed_iterator_t<IR>, borrowed_iterator_t<OR>>    uninitialized_copy(IR&& in_range, OR&& out_range);// freestanding template<class I,class O>using uninitialized_copy_n_result= in_out_result<I, O>;// freestandingtemplate<input_iterator I,no-throw-forward-iterator O,             no-throw-sentinel-for<O> S>      requires constructible_from<iter_value_t<O>, iter_reference_t<I>>constexpr uninitialized_copy_n_result<I, O> uninitialized_copy_n(      I ifirst,      iter_difference_t<I> n,// freestanding      O ofirst,      S olast);} template<class InputIter,class NoThrowForwardIter>constexpr NoThrowForwardIter uninitialized_move(InputIter first,// freestanding                                                  InputIter last,                                                  NoThrowForwardIter result);template<class ExecutionPolicy,class ForwardIter,class NoThrowForwardIter>  NoThrowForwardIter uninitialized_move(ExecutionPolicy&& exec,// freestanding-deleted,                                        ForwardIter first,                                        ForwardIter last,                                        NoThrowForwardIter result);template<class InputIter,class Size,class NoThrowForwardIter>constexpr pair<InputIter, NoThrowForwardIter> uninitialized_move_n(    InputIter first,    Size n,// freestanding    NoThrowForwardIter result);template<class ExecutionPolicy,class ForwardIter,class Size,class NoThrowForwardIter>  pair<ForwardIter, NoThrowForwardIter> uninitialized_move_n(    ExecutionPolicy&& exec,// freestanding-deleted,    ForwardIter first,    Size n,    NoThrowForwardIter result); namespace ranges{template<class I,class O>using uninitialized_move_result= in_out_result<I, O>;// freestandingtemplate<input_iterator I,             sentinel_for<I> S1,no-throw-forward-iterator O,             no-throw-sentinel-for<O> S2>      requires constructible_from<iter_value_t<O>, iter_rvalue_reference_t<I>>constexpr uninitialized_move_result<I, O>    uninitialized_move(I ifirst, S1 ilast, O ofirst, S2 olast);// freestandingtemplate<input_range IR,no-throw-forward-range OR>      requires constructible_from<range_value_t<OR>, range_rvalue_reference_t<IR>>constexpr uninitialized_move_result<borrowed_iterator_t<IR>, borrowed_iterator_t<OR>>    uninitialized_move(IR&& in_range, OR&& out_range);// freestanding template<class I,class O>using uninitialized_move_n_result= in_out_result<I, O>;// freestandingtemplate<input_iterator I,no-throw-forward-iterator O,             no-throw-sentinel-for<O> S>      requires constructible_from<iter_value_t<O>, iter_rvalue_reference_t<I>>constexpr uninitialized_move_n_result<I, O> uninitialized_move_n(      I ifirst,      iter_difference_t<I> n,// freestanding      O ofirst,      S olast);} template<class NoThrowForwardIter,class T>constexprvoid uninitialized_fill(NoThrowForwardIter first,// freestanding                                    NoThrowForwardIter last,const T& x);template<class ExecutionPolicy,class NoThrowForwardIter,class T>void uninitialized_fill(ExecutionPolicy&& exec,// freestanding-deleted,                          NoThrowForwardIter first,                          NoThrowForwardIter last,const T& x);template<class NoThrowForwardIter,class Size,class T>constexpr NoThrowForwardIter uninitialized_fill_n(NoThrowForwardIter first,                                                    Size n,const T& x);// freestandingtemplate<class ExecutionPolicy,class NoThrowForwardIter,class Size,class T>  NoThrowForwardIter uninitialized_fill_n(ExecutionPolicy&& exec,// freestanding-deleted,                                          NoThrowForwardIter first,                                          Size n,const T& x); namespace ranges{template<no-throw-forward-iterator I, no-throw-sentinel-for<I> S,class T>      requires constructible_from<iter_value_t<I>,const T&>constexpr I uninitialized_fill(I first, S last,const T& x);// freestandingtemplate<no-throw-forward-range R,class T>      requires constructible_from<range_value_t<R>,const T&>constexpr borrowed_iterator_t<R> uninitialized_fill(R&& r,const T& x);// freestanding template<no-throw-forward-iterator I,class T>      requires constructible_from<iter_value_t<I>,const T&>constexpr I uninitialized_fill_n(I first,// freestanding                                     iter_difference_t<I> n,const T& x);} // construct_attemplate<class T,class...Args>constexpr T* construct_at(T* location, Args&&...args);// freestanding namespace ranges{template<class T,class...Args>constexpr T* construct_at(T* location, Args&&...args);// freestanding} // destroytemplate<class T>constexprvoid destroy_at(T* location);// freestandingtemplate<class NoThrowForwardIter>constexprvoid destroy(NoThrowForwardIter first,// freestanding                         NoThrowForwardIter last);template<class ExecutionPolicy,class NoThrowForwardIter>void destroy(ExecutionPolicy&& exec,// freestanding-deleted,               NoThrowForwardIter first,               NoThrowForwardIter last);template<class NoThrowForwardIter,class Size>constexpr NoThrowForwardIter destroy_n(NoThrowForwardIter first,// freestanding                                         Size n);template<class ExecutionPolicy,class NoThrowForwardIter,class Size>  NoThrowForwardIter destroy_n(ExecutionPolicy&& exec,// freestanding-deleted,                               NoThrowForwardIter first,                               Size n); namespace ranges{template<destructible T>constexprvoid destroy_at(T* location)noexcept;// freestanding template<no-throw-input-iterator I, no-throw-sentinel-for<I> S>      requires destructible<iter_value_t<I>>constexpr I destroy(I first, S last)noexcept;// freestandingtemplate<no-throw-input-range R>      requires destructible<range_value_t<R>>constexpr borrowed_iterator_t<R> destroy(R&& r)noexcept;// freestanding template<no-throw-input-iterator I>      requires destructible<iter_value_t<I>>constexpr I destroy_n(I first, iter_difference_t<I> n)noexcept;// freestanding} // class template unique_ptrtemplate<class T>struct default_delete;// freestandingtemplate<class T>struct default_delete<T[]>;// freestandingtemplate<class T,class D= default_delete<T>>class unique_ptr;// freestandingtemplate<class T,class D>class unique_ptr<T[], D>;// freestanding template<class T,class...Args>constexpr unique_ptr<T> make_unique(Args&&...args);// T is not arraytemplate<class T>constexpr unique_ptr<T> make_unique(size_t n);// T is U[]template<class T,class...Args>/* unspecified */ make_unique(Args&&...)= delete;// T is U[N] template<class T>constexpr unique_ptr<T> make_unique_for_overwrite();// T is not arraytemplate<class T>constexpr unique_ptr<T> make_unique_for_overwrite(size_t n);// T is U[]template<class T,class...Args>/* unspecified */ make_unique_for_overwrite(Args&&...)= delete;// T is U[N] template<class T,class D>constexprvoid swap(unique_ptr<T, D>& x, unique_ptr<T, D>& y)noexcept;// freestanding template<class T1,class D1,class T2,class D2>constexprbool operator==(const unique_ptr<T1, D1>& x,// freestandingconst unique_ptr<T2, D2>& y);template<class T1,class D1,class T2,class D2>bool operator<(const unique_ptr<T1, D1>& x,const unique_ptr<T2, D2>& y);// freestandingtemplate<class T1,class D1,class T2,class D2>bool operator>(const unique_ptr<T1, D1>& x,const unique_ptr<T2, D2>& y);// freestandingtemplate<class T1,class D1,class T2,class D2>bool operator<=(const unique_ptr<T1, D1>& x,const unique_ptr<T2, D2>& y);// freestandingtemplate<class T1,class D1,class T2,class D2>bool operator>=(const unique_ptr<T1, D1>& x,const unique_ptr<T2, D2>& y);// freestandingtemplate<class T1,class D1,class T2,class D2>    requires three_way_comparable_with<typename unique_ptr<T1, D1>::pointer,typename unique_ptr<T2, D2>::pointer>  compare_three_way_result_t<typename unique_ptr<T1, D1>::pointer,typename unique_ptr<T2, D2>::pointer>  operator<=>(const unique_ptr<T1, D1>& x,const unique_ptr<T2, D2>& y);// freestanding template<class T,class D>constexprbool operator==(const unique_ptr<T, D>& x,                            nullptr_t)noexcept;// freestandingtemplate<class T,class D>constexprbool operator<(const unique_ptr<T, D>& x, nullptr_t);// freestandingtemplate<class T,class D>constexprbool operator<(nullptr_t,const unique_ptr<T, D>& y);// freestandingtemplate<class T,class D>constexprbool operator>(const unique_ptr<T, D>& x, nullptr_t);// freestandingtemplate<class T,class D>constexprbool operator>(nullptr_t,const unique_ptr<T, D>& y);// freestandingtemplate<class T,class D>constexprbool operator<=(const unique_ptr<T, D>& x, nullptr_t);// freestandingtemplate<class T,class D>constexprbool operator<=(nullptr_t,const unique_ptr<T, D>& y);// freestandingtemplate<class T,class D>constexprbool operator>=(const unique_ptr<T, D>& x, nullptr_t);// freestandingtemplate<class T,class D>constexprbool operator>=(nullptr_t,const unique_ptr<T, D>& y);// freestandingtemplate<class T,class D>    requires three_way_comparable<typename unique_ptr<T, D>::pointer>constexpr compare_three_way_result_t<typename unique_ptr<T, D>::pointer> operator<=>(const unique_ptr<T, D>& x,    nullptr_t);// freestanding template<class E,class T,class Y,class D>  basic_ostream<E, T>& operator<<(basic_ostream<E, T>& os,const unique_ptr<Y, D>& p); // class bad_weak_ptrclass bad_weak_ptr; // class template shared_ptrtemplate<class T>class shared_ptr; // shared_ptr creationtemplate<class T,class...Args>  shared_ptr<T> make_shared(Args&&...args);// T is not arraytemplate<class T,class A,class...Args>  shared_ptr<T> allocate_shared(const A& a, Args&&...args);// T is not array template<class T>  shared_ptr<T> make_shared(size_t N);// T is U[]template<class T,class A>  shared_ptr<T> allocate_shared(const A& a, size_t N);// T is U[] template<class T>  shared_ptr<T> make_shared();// T is U[N]template<class T,class A>  shared_ptr<T> allocate_shared(const A& a);// T is U[N] template<class T>  shared_ptr<T> make_shared(size_t N,const remove_extent_t<T>& u);// T is U[]template<class T,class A>  shared_ptr<T> allocate_shared(const A& a,                                size_t N,const remove_extent_t<T>& u);// T is U[] template<class T>  shared_ptr<T> make_shared(const remove_extent_t<T>& u);// T is U[N]template<class T,class A>  shared_ptr<T> allocate_shared(const A& a,const remove_extent_t<T>& u);// T is U[N] template<class T>  shared_ptr<T> make_shared_for_overwrite();// T is not U[]template<class T,class A>  shared_ptr<T> allocate_shared_for_overwrite(const A& a);// T is not U[] template<class T>  shared_ptr<T> make_shared_for_overwrite(size_t N);// T is U[]template<class T,class A>  shared_ptr<T> allocate_shared_for_overwrite(const A& a, size_t N);// T is U[] // shared_ptr comparisonstemplate<class T,class U>bool operator==(const shared_ptr<T>& a,const shared_ptr<U>& b)noexcept;template<class T,class U>  strong_ordering operator<=>(const shared_ptr<T>& a,const shared_ptr<U>& b)noexcept; template<class T>bool operator==(const shared_ptr<T>& x, nullptr_t)noexcept;template<class T>  strong_ordering operator<=>(const shared_ptr<T>& x, nullptr_t)noexcept; // shared_ptr specialized algorithmstemplate<class T>void swap(shared_ptr<T>& a, shared_ptr<T>& b)noexcept; // shared_ptr caststemplate<class T,class U>  shared_ptr<T> static_pointer_cast(const shared_ptr<U>& r)noexcept;template<class T,class U>  shared_ptr<T> static_pointer_cast(shared_ptr<U>&& r)noexcept;template<class T,class U>  shared_ptr<T> dynamic_pointer_cast(const shared_ptr<U>& r)noexcept;template<class T,class U>  shared_ptr<T> dynamic_pointer_cast(shared_ptr<U>&& r)noexcept;template<class T,class U>  shared_ptr<T> const_pointer_cast(const shared_ptr<U>& r)noexcept;template<class T,class U>  shared_ptr<T> const_pointer_cast(shared_ptr<U>&& r)noexcept;template<class T,class U>  shared_ptr<T> reinterpret_pointer_cast(const shared_ptr<U>& r)noexcept;template<class T,class U>  shared_ptr<T> reinterpret_pointer_cast(shared_ptr<U>&& r)noexcept; // shared_ptr get_deletertemplate<class D,class T>  D* get_deleter(const shared_ptr<T>& p)noexcept; // shared_ptr I/Otemplate<class E,class T,class Y>  basic_ostream<E, T>& operator<<(basic_ostream<E, T>& os,const shared_ptr<Y>& p); // class template weak_ptrtemplate<class T>class weak_ptr; // weak_ptr specialized algorithmstemplate<class T>void swap(weak_ptr<T>& a, weak_ptr<T>& b)noexcept; // class template owner_lesstemplate<class T=void>struct owner_less; // struct owner_hashstruct owner_hash; // struct owner_equalstruct owner_equal; // class template enable_shared_from_thistemplate<class T>class enable_shared_from_this; // hash supporttemplate<class T>struct hash;// freestandingtemplate<class T,class D>struct hash<unique_ptr<T, D>>;// freestandingtemplate<class T>struct hash<shared_ptr<T>>; // atomic smart pointerstemplate<class T>struct atomic;// freestandingtemplate<class T>struct atomic<shared_ptr<T>>;template<class T>struct atomic<weak_ptr<T>>; // class template out_ptr_ttemplate<class Smart,class Pointer,class...Args>class out_ptr_t;// freestanding // function template out_ptrtemplate<class Pointer=void,class Smart,class...Args>auto out_ptr(Smart& s, Args&&...args);// freestanding // class template inout_ptr_ttemplate<class Smart,class Pointer,class...Args>class inout_ptr_t;// freestanding // function template inout_ptrtemplate<class Pointer=void,class Smart,class...Args>auto inout_ptr(Smart& s, Args&&...args);// freestanding // class template indirecttemplate<class T,class Allocator= allocator<T>>class indirect; // hash supporttemplate<class T,class Alloc>struct hash<indirect<T, Alloc>>; // class template polymorphictemplate<class T,class Allocator= allocator<T>>class polymorphic; namespace pmr{template<class T>using indirect= indirect<T, polymorphic_allocator<T>>;template<class T>using polymorphic= polymorphic<T, polymorphic_allocator<T>>;}}

      [edit]Helper concepts

      Note:These names are only for exposition, they are not part of the interface.

      template<class I>conceptno-throw-input-iterator=// exposition only  input_iterator<I>&&  is_lvalue_reference_v<iter_reference_t<I>>&&  same_as<remove_cvref_t<iter_reference_t<I>>, iter_value_t<I>>; template<class S,class I>concept no-throw-sentinel-for= sentinel_for<S, I>;// exposition only template<class R>conceptno-throw-input-range=// exposition onlyranges::range<R>&&no-throw-input-iterator<ranges::iterator_t<R>>&&  no-throw-sentinel-for<ranges::sentinel_t<R>,ranges::iterator_t<R>>; template<class I>conceptno-throw-forward-iterator=// exposition onlyno-throw-input-iterator<I>&&  forward_iterator<I>&&  no-throw-sentinel-for<I, I>; template<class R>conceptno-throw-forward-range=// exposition onlyno-throw-input-range<R>&&no-throw-forward-iterator<ranges::iterator_t<R>>;

      [edit]Class templatestd::pointer_traits

      namespace std{template<class Ptr>struct pointer_traits{/* see description */;}; template<class T>struct pointer_traits<T*>{using pointer= T*;using element_type= T;using difference_type= ptrdiff_t; template<class U>using rebind= U*; staticconstexpr pointer pointer_to(/* see description */ r)noexcept;};}

      [edit]Classstd::allocator_arg_t

      namespace std{struct allocator_arg_t{explicit allocator_arg_t()=default;};inlineconstexpr allocator_arg_t allocator_arg{};}

      [edit]Class templatestd::allocator_traits

      namespace std{template<class Alloc>struct allocator_traits{using allocator_type= Alloc; using value_type=typename Alloc::value_type; using pointer=/* see description */;using const_pointer=/* see description */;using void_pointer=/* see description */;using const_void_pointer=/* see description */; using difference_type=/* see description */;using size_type=/* see description */; using propagate_on_container_copy_assignment=/* see description */;using propagate_on_container_move_assignment=/* see description */;using propagate_on_container_swap=/* see description */;using is_always_equal=/* see description */; template<class T>using rebind_alloc=/* see description */;template<class T>using rebind_traits= allocator_traits<rebind_alloc<T>>; staticconstexpr pointer allocate(Alloc& a, size_type n);staticconstexpr pointer allocate(Alloc& a, size_type n, const_void_pointer hint);staticconstexpr allocation_result<pointer, size_type> allocate_at_least(Alloc& a,                                                                             size_type n); staticconstexprvoid deallocate(Alloc& a, pointer p, size_type n); template<class T,class...Args>staticconstexprvoid construct(Alloc& a, T* p, Args&&...args); template<class T>staticconstexprvoid destroy(Alloc& a, T* p); staticconstexpr size_type max_size(const Alloc& a)noexcept; staticconstexpr Alloc select_on_container_copy_construction(const Alloc& rhs);};}

      [edit]Class templatestd::allocator

      namespace std{template<class T>class allocator{public:using value_type= T;using size_type= size_t;using difference_type= ptrdiff_t;using propagate_on_container_move_assignment= true_type; constexpr allocator()noexcept;constexpr allocator(const allocator&)noexcept;template<class U>constexpr allocator(const allocator<U>&)noexcept;constexpr ~allocator();constexpr allocator& operator=(const allocator&)=default; constexpr T* allocate(size_t n);constexpr allocation_result<T*> allocate_at_least(size_t n);constexprvoid deallocate(T* p, size_t n);};}

      [edit]Class templatestd::default_delete

      namespace std{template<class T>struct default_delete{constexpr default_delete()noexcept=default;template<class U>constexpr default_delete(const default_delete<U>&)noexcept;constexprvoid operator()(T*)const;}; template<class T>struct default_delete<T[]>{constexpr default_delete()noexcept=default;template<class U>constexpr default_delete(const default_delete<U[]>&)noexcept;template<class U>constexprvoid operator()(U* ptr)const;};}

      [edit]Class templatestd::unique_ptr

      namespace std{template<class T,class D= default_delete<T>>class unique_ptr{public:using pointer=/* see description */;using element_type= T;using deleter_type= D; // constructorsconstexpr unique_ptr()noexcept;constexprexplicit unique_ptr(type_identity_t<pointer> p)noexcept;constexpr unique_ptr(type_identity_t<pointer> p,/* see description */ d1)noexcept;constexpr unique_ptr(type_identity_t<pointer> p,/* see description */ d2)noexcept;constexpr unique_ptr(unique_ptr&& u)noexcept;constexpr unique_ptr(nullptr_t)noexcept;template<class U,class E>constexpr unique_ptr(unique_ptr<U, E>&& u)noexcept; // destructorconstexpr ~unique_ptr(); // assignmentconstexpr unique_ptr& operator=(unique_ptr&& u)noexcept;template<class U,class E>constexpr unique_ptr& operator=(unique_ptr<U, E>&& u)noexcept;constexpr unique_ptr& operator=(nullptr_t)noexcept; // observersconstexpr add_lvalue_reference_t<T> operator*()constnoexcept(/* see description */);constexpr pointer operator->()constnoexcept;constexpr pointer get()constnoexcept;constexpr deleter_type& get_deleter()noexcept;constexprconst deleter_type& get_deleter()constnoexcept;constexprexplicit operatorbool()constnoexcept; // modifiersconstexpr pointer release()noexcept;constexprvoid reset(pointer p= pointer())noexcept;constexprvoid swap(unique_ptr& u)noexcept; // disable copy from lvalue    unique_ptr(const unique_ptr&)= delete;    unique_ptr& operator=(const unique_ptr&)= delete;}; template<class T,class D>class unique_ptr<T[], D>{public:using pointer=/* see description */;using element_type= T;using deleter_type= D; // constructorsconstexpr unique_ptr()noexcept;template<class U>constexprexplicit unique_ptr(U p)noexcept;template<class U>constexpr unique_ptr(U p,/* see description */ d)noexcept;template<class U>constexpr unique_ptr(U p,/* see description */ d)noexcept;constexpr unique_ptr(unique_ptr&& u)noexcept;template<class U,class E>constexpr unique_ptr(unique_ptr<U, E>&& u)noexcept;constexpr unique_ptr(nullptr_t)noexcept; // destructorconstexpr ~unique_ptr(); // assignmentconstexpr unique_ptr& operator=(unique_ptr&& u)noexcept;template<class U,class E>constexpr unique_ptr& operator=(unique_ptr<U, E>&& u)noexcept;constexpr unique_ptr& operator=(nullptr_t)noexcept; // observersconstexpr T& operator[](size_t i)const;constexpr pointer get()constnoexcept;constexpr deleter_type& get_deleter()noexcept;constexprconst deleter_type& get_deleter()constnoexcept;constexprexplicit operatorbool()constnoexcept; // modifiersconstexpr pointer release()noexcept;template<class U>constexprvoid reset(U p)noexcept;constexprvoid reset(nullptr_t= nullptr)noexcept;constexprvoid swap(unique_ptr& u)noexcept; // disable copy from lvalue    unique_ptr(const unique_ptr&)= delete;    unique_ptr& operator=(const unique_ptr&)= delete;};}

      [edit]Classstd::bad_weak_ptr

      namespace std{class bad_weak_ptr:public exception{public:// for the specification of the special member functionsconstchar* what()constnoexcept override;};}

      [edit]Class templatestd::shared_ptr

      namespace std{template<class T>class shared_ptr{public:using element_type= remove_extent_t<T>;using weak_type= weak_ptr<T>; // constructorsconstexpr shared_ptr()noexcept;constexpr shared_ptr(nullptr_t)noexcept: shared_ptr(){}template<class Y>explicit shared_ptr(Y* p);template<class Y,class D>    shared_ptr(Y* p, D d);template<class Y,class D,class A>    shared_ptr(Y* p, D d, A a);template<class D>    shared_ptr(nullptr_t p, D d);template<class D,class A>    shared_ptr(nullptr_t p, D d, A a);template<class Y>    shared_ptr(const shared_ptr<Y>& r, element_type* p)noexcept;template<class Y>    shared_ptr(shared_ptr<Y>&& r, element_type* p)noexcept;    shared_ptr(const shared_ptr& r)noexcept;template<class Y>    shared_ptr(const shared_ptr<Y>& r)noexcept;    shared_ptr(shared_ptr&& r)noexcept;template<class Y>    shared_ptr(shared_ptr<Y>&& r)noexcept;template<class Y>explicit shared_ptr(const weak_ptr<Y>& r);template<class Y,class D>    shared_ptr(unique_ptr<Y, D>&& r); // destructor    ~shared_ptr(); // assignment    shared_ptr& operator=(const shared_ptr& r)noexcept;template<class Y>    shared_ptr& operator=(const shared_ptr<Y>& r)noexcept;    shared_ptr& operator=(shared_ptr&& r)noexcept;template<class Y>    shared_ptr& operator=(shared_ptr<Y>&& r)noexcept;template<class Y,class D>    shared_ptr& operator=(unique_ptr<Y, D>&& r); // modifiersvoid swap(shared_ptr& r)noexcept;void reset()noexcept;template<class Y>void reset(Y* p);template<class Y,class D>void reset(Y* p, D d);template<class Y,class D,class A>void reset(Y* p, D d, A a); // observers    element_type* get()constnoexcept;    T& operator*()constnoexcept;    T* operator->()constnoexcept;    element_type& operator[](ptrdiff_t i)const;long use_count()constnoexcept;explicit operatorbool()constnoexcept;template<class U>bool owner_before(const shared_ptr<U>& b)constnoexcept;template<class U>bool owner_before(const weak_ptr<U>& b)constnoexcept;    size_t owner_hash()constnoexcept;template<class U>bool owner_equal(const shared_ptr<U>& b)constnoexcept;template<class U>bool owner_equal(const weak_ptr<U>& b)constnoexcept;}; template<class T>  shared_ptr(weak_ptr<T>)-> shared_ptr<T>;template<class T,class D>  shared_ptr(unique_ptr<T, D>)-> shared_ptr<T>;}

      [edit]Class templatestd::weak_ptr

      namespace std{template<class T>class weak_ptr{public:using element_type= remove_extent_t<T>; // constructorsconstexpr weak_ptr()noexcept;template<class Y>    weak_ptr(const shared_ptr<Y>& r)noexcept;    weak_ptr(const weak_ptr& r)noexcept;template<class Y>    weak_ptr(const weak_ptr<Y>& r)noexcept;    weak_ptr(weak_ptr&& r)noexcept;template<class Y>    weak_ptr(weak_ptr<Y>&& r)noexcept; // destructor    ~weak_ptr(); // assignment    weak_ptr& operator=(const weak_ptr& r)noexcept;template<class Y>    weak_ptr& operator=(const weak_ptr<Y>& r)noexcept;template<class Y>    weak_ptr& operator=(const shared_ptr<Y>& r)noexcept;    weak_ptr& operator=(weak_ptr&& r)noexcept;template<class Y>    weak_ptr& operator=(weak_ptr<Y>&& r)noexcept; // modifiersvoid swap(weak_ptr& r)noexcept;void reset()noexcept; // observerslong use_count()constnoexcept;bool expired()constnoexcept;    shared_ptr<T> lock()constnoexcept;template<class U>bool owner_before(const shared_ptr<U>& b)constnoexcept;template<class U>bool owner_before(const weak_ptr<U>& b)constnoexcept;    size_t owner_hash()constnoexcept;template<class U>bool owner_equal(const shared_ptr<U>& b)constnoexcept;template<class U>bool owner_equal(const weak_ptr<U>& b)constnoexcept;}; template<class T>  weak_ptr(shared_ptr<T>)-> weak_ptr<T>;}

      [edit]Class templatestd::owner_less

      namespace std{template<class T=void>struct owner_less; template<class T>struct owner_less<shared_ptr<T>>{bool operator()(const shared_ptr<T>&,const shared_ptr<T>&)constnoexcept;bool operator()(const shared_ptr<T>&,const weak_ptr<T>&)constnoexcept;bool operator()(const weak_ptr<T>&,const shared_ptr<T>&)constnoexcept;}; template<class T>struct owner_less<weak_ptr<T>>{bool operator()(const weak_ptr<T>&,const weak_ptr<T>&)constnoexcept;bool operator()(const shared_ptr<T>&,const weak_ptr<T>&)constnoexcept;bool operator()(const weak_ptr<T>&,const shared_ptr<T>&)constnoexcept;}; template<>struct owner_less<void>{template<class T,class U>bool operator()(const shared_ptr<T>&,const shared_ptr<U>&)constnoexcept;template<class T,class U>bool operator()(const shared_ptr<T>&,const weak_ptr<U>&)constnoexcept;template<class T,class U>bool operator()(const weak_ptr<T>&,const shared_ptr<U>&)constnoexcept;template<class T,class U>bool operator()(const weak_ptr<T>&,const weak_ptr<U>&)constnoexcept; using is_transparent=/* unspecified */;};}

      [edit]Classstd::owner_hash

      namespace std{struct owner_hash{template<class T>    size_t operator()(const shared_ptr<T>&)constnoexcept; template<class T>    size_t operator()(const weak_ptr<T>&)constnoexcept; using is_transparent=/* unspecified */;};}

      [edit]Classstd::owner_equal

      namespace std{struct owner_equal{template<class T,class U>bool operator()(const shared_ptr<T>&,const shared_ptr<U>&)constnoexcept;template<class T,class U>bool operator()(const shared_ptr<T>&,const weak_ptr<U>&)constnoexcept;template<class T,class U>bool operator()(const weak_ptr<T>&,const shared_ptr<U>&)constnoexcept;template<class T,class U>bool operator()(const weak_ptr<T>&,const weak_ptr<U>&)constnoexcept; using is_transparent=/* unspecified */;};}

      [edit]Class templatestd::enable_shared_from_this

      namespace std{template<class T>class enable_shared_from_this{protected:constexpr enable_shared_from_this()noexcept;    enable_shared_from_this(const enable_shared_from_this&)noexcept;    enable_shared_from_this& operator=(const enable_shared_from_this&)noexcept;    ~enable_shared_from_this(); public:    shared_ptr<T> shared_from_this();    shared_ptr<Tconst> shared_from_this()const;    weak_ptr<T> weak_from_this()noexcept;    weak_ptr<Tconst> weak_from_this()constnoexcept; private:    mutable weak_ptr<T>/*weak-this*/;// exposition-only};}

      [edit]Class templatestd::atomic's specialization forstd::shared_ptr

      namespace std{template<class T>struct atomic<shared_ptr<T>>{using value_type= shared_ptr<T>;staticconstexprbool is_always_lock_free=/* implementation-defined */; bool is_lock_free()constnoexcept;void store(shared_ptr<T> desired, memory_order order= memory_order::seq_cst)noexcept;    shared_ptr<T> load(memory_order order= memory_order::seq_cst)constnoexcept;    operator shared_ptr<T>()constnoexcept;     shared_ptr<T> exchange(shared_ptr<T> desired,                           memory_order order= memory_order::seq_cst)noexcept; bool compare_exchange_weak(shared_ptr<T>& expected, shared_ptr<T> desired,                               memory_order success, memory_order failure)noexcept;bool compare_exchange_strong(shared_ptr<T>& expected, shared_ptr<T> desired,                                 memory_order success, memory_order failure)noexcept; bool compare_exchange_weak(shared_ptr<T>& expected, shared_ptr<T> desired,                               memory_order order= memory_order::seq_cst)noexcept;bool compare_exchange_strong(shared_ptr<T>& expected, shared_ptr<T> desired,                                 memory_order order= memory_order::seq_cst)noexcept; constexpr atomic()noexcept=default;    atomic(shared_ptr<T> desired)noexcept;    atomic(const atomic&)= delete;void operator=(const atomic&)= delete;void operator=(shared_ptr<T> desired)noexcept; private:    shared_ptr<T> p;// exposition only};}

      [edit]Class templatestd::atomic's specialization forstd::weak_ptr

      namespace std{template<class T>struct atomic<weak_ptr<T>>{using value_type= weak_ptr<T>;staticconstexprbool is_always_lock_free=/* implementation-defined */; bool is_lock_free()constnoexcept;void store(weak_ptr<T> desired, memory_order order= memory_order::seq_cst)noexcept;    weak_ptr<T> load(memory_order order= memory_order::seq_cst)constnoexcept;    operator weak_ptr<T>()constnoexcept;     weak_ptr<T> exchange(weak_ptr<T> desired,                         memory_order order= memory_order::seq_cst)noexcept; bool compare_exchange_weak(weak_ptr<T>& expected, weak_ptr<T> desired,                               memory_order success, memory_order failure)noexcept;bool compare_exchange_strong(weak_ptr<T>& expected, weak_ptr<T> desired,                                 memory_order success, memory_order failure)noexcept; bool compare_exchange_weak(weak_ptr<T>& expected, weak_ptr<T> desired,                               memory_order order= memory_order::seq_cst)noexcept;bool compare_exchange_strong(weak_ptr<T>& expected, weak_ptr<T> desired,                                 memory_order order= memory_order::seq_cst)noexcept; constexpr atomic()noexcept=default;    atomic(weak_ptr<T> desired)noexcept;    atomic(const atomic&)= delete;void operator=(const atomic&)= delete;void operator=(weak_ptr<T> desired)noexcept; private:    weak_ptr<T> p;// exposition only};}

      [edit]Class templatestd::out_ptr_t

      namespace std{template<class Smart,class Pointer,class...Args>class out_ptr_t{public:explicit out_ptr_t(Smart&, Args...);    out_ptr_t(const out_ptr_t&)= delete;     ~out_ptr_t();     operator Pointer*()constnoexcept;    operatorvoid**()constnoexcept; private:    Smart& s;// exposition-only    tuple<Args...> a;// exposition-only    Pointer p;// exposition-only};}

      [edit]Class templatestd::inout_ptr_t

      namespace std{template<class Smart,class Pointer,class...Args>class inout_ptr_t{public:explicit inout_ptr_t(Smart&, Args...);    inout_ptr_t(const inout_ptr_t&)= delete;     ~inout_ptr_t();     operator Pointer*()constnoexcept;    operatorvoid**()constnoexcept; private:    Smart& s;// exposition-only    tuple<Args...> a;// exposition-only    Pointer p;// exposition-only};}

      [edit]Class templatestd::indirect

      namespace std{template<class T,class Allocator= allocator<T>>class indirect{public:using value_type= T;using allocator_type= Allocator;using pointer=typename allocator_traits<Allocator>::pointer;using const_pointer=typename allocator_traits<Allocator>::const_pointer; // constructorsconstexprexplicit indirect();constexprexplicit indirect(allocator_arg_t,const Allocator& a);constexpr indirect(const indirect& other);constexpr indirect(allocator_arg_t,const Allocator& a,const indirect& other);constexpr indirect(indirect&& other)noexcept;constexpr indirect(allocator_arg_t,const Allocator& a,                       indirect&& other)noexcept(/* see description */);template<class U= T>constexprexplicit indirect(U&& u);template<class U= T>constexprexplicit indirect(allocator_arg_t,const Allocator& a, U&& u);template<class...Us>constexprexplicit indirect(in_place_t, Us&&...us);template<class...Us>constexprexplicit indirect(allocator_arg_t,const Allocator& a,                                in_place_t,                                Us&&...us);template<class I,class...Us>constexprexplicit indirect(in_place_t, initializer_list<I> ilist, Us&&...us);template<class I,class...Us>constexprexplicit indirect(allocator_arg_t,const Allocator& a,                                in_place_t,                                initializer_list<I> ilist,                                Us&&...us); // destructorconstexpr ~indirect(); // assignmentconstexpr indirect& operator=(const indirect& other);constexpr indirect& operator=(indirect&& other)noexcept(/* see description */);template<class U= T>constexpr indirect& operator=(U&& u); // observersconstexprconst T& operator*()const&noexcept;constexpr T& operator*()&noexcept;constexprconst T&& operator*()const&&noexcept;constexpr T&& operator*()&&noexcept;constexpr const_pointer operator->()constnoexcept;constexpr pointer operator->()noexcept;constexprbool valueless_after_move()constnoexcept;constexpr allocator_type get_allocator()constnoexcept; // swapconstexprvoid swap(indirect& other)noexcept(/* see description */);friendconstexprvoid swap(indirect& lhs,                               indirect& rhs)noexcept(/* see description */); // relational operatorstemplate<class U,class AA>friendconstexprbool operator==(const indirect& lhs,const indirect<U, AA>& rhs)noexcept(/* see description */);template<class U,class AA>friendconstexprauto operator<=>(const indirect& lhs,const indirect<U, AA>& rhs)->/*synth-three-way-result*/<T, U>; // comparison with Ttemplate<class U>friendconstexprbool operator==(const indirect& lhs,const U& rhs)noexcept(/* see description */);template<class U>friendconstexprauto operator<=>(const indirect& lhs,const U& rhs)->/*synth-three-way-result*/<T, U>; private:    pointer/*p*/;// exposition-only    Allocator/*alloc*/= Allocator();// exposition-only};template<class Value>  indirect(Value)-> indirect<Value>;template<class Allocator,class Value>  indirect(allocator_arg_t, Allocator, Value)-> indirect<Value,typename allocator_traits<Allocator>::template rebind_alloc<Value>>;}

      [edit]Class templatestd::polymorphic

      namespace std{template<class T,class Allocator= allocator<T>>class polymorphic{public:using value_type= T;using allocator_type= Allocator;using pointer=typename allocator_traits<Allocator>::pointer;using const_pointer=typename allocator_traits<Allocator>::const_pointer; // constructorsconstexprexplicit polymorphic();constexprexplicit polymorphic(allocator_arg_t,const Allocator& a);constexpr polymorphic(const polymorphic& other);constexpr polymorphic(allocator_arg_t,const Allocator& a,const polymorphic& other);constexpr polymorphic(polymorphic&& other)noexcept;constexpr polymorphic(allocator_arg_t,const Allocator& a,                          polymorphic&& other)noexcept(/* see description */);template<class U= T>constexprexplicit polymorphic(U&& u);template<class U= T>constexprexplicit polymorphic(allocator_arg_t,const Allocator& a, U&& u);template<class U,class...Ts>constexprexplicit polymorphic(in_place_type_t<U>, Ts&&...ts);template<class U,class...Ts>constexprexplicit polymorphic(allocator_arg_t,const Allocator& a,                                   in_place_type_t<U>,                                   Ts&&...ts);template<class U,class I,class...Us>constexprexplicit polymorphic(in_place_type_t<U>,                                   initializer_list<I> ilist,                                   Us&&...us);template<class U,class I,class...Us>constexprexplicit polymorphic(allocator_arg_t,const Allocator& a,                                   in_place_type_t<U>,                                   initializer_list<I> ilist,                                   Us&&...us); // destructorconstexpr ~polymorphic(); // assignmentconstexpr polymorphic& operator=(const polymorphic& other);constexpr polymorphic& operator=(polymorphic&& other)noexcept(/* see description */); // observersconstexprconst T& operator*()constnoexcept;constexpr T& operator*()noexcept;constexpr const_pointer operator->()constnoexcept;constexpr pointer operator->()noexcept;constexprbool valueless_after_move()constnoexcept;constexpr allocator_type get_allocator()constnoexcept; // swapconstexprvoid swap(polymorphic& other)noexcept(/* see description */);friendconstexprvoid swap(polymorphic& lhs,                               polymorphic& rhs)noexcept(/* see description */); private:    Allocator/*alloc*/= Allocator();// exposition-only};}
      Retrieved from "https://en.cppreference.com/mwiki/index.php?title=cpp/header/memory&oldid=182611"

      [8]ページ先頭

      ©2009-2025 Movatter.jp