// -*- C++ -*- //===----------------------------------------------------------------------===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// #ifndef _LIBCPP_MEMORY #define _LIBCPP_MEMORY // clang-format off /* memory synopsis namespace std { struct allocator_arg_t { }; inline constexpr allocator_arg_t allocator_arg = allocator_arg_t(); template struct uses_allocator; template struct pointer_traits { typedef Ptr pointer; typedef
element_type; typedef
difference_type; template using rebind =
; static pointer pointer_to(
); }; template struct pointer_traits { typedef T* pointer; typedef T element_type; typedef ptrdiff_t difference_type; template using rebind = U*; static pointer pointer_to(
) noexcept; // constexpr in C++20 }; template constexpr T* to_address(T* p) noexcept; // C++20 template constexpr auto to_address(const Ptr& p) noexcept; // C++20 template struct allocator_traits { typedef Alloc allocator_type; typedef typename allocator_type::value_type value_type; typedef Alloc::pointer | value_type* pointer; typedef Alloc::const_pointer | pointer_traits::rebind const_pointer; typedef Alloc::void_pointer | pointer_traits::rebind void_pointer; typedef Alloc::const_void_pointer | pointer_traits::rebind const_void_pointer; typedef Alloc::difference_type | pointer_traits::difference_type difference_type; typedef Alloc::size_type | make_unsigned::type size_type; typedef Alloc::propagate_on_container_copy_assignment | false_type propagate_on_container_copy_assignment; typedef Alloc::propagate_on_container_move_assignment | false_type propagate_on_container_move_assignment; typedef Alloc::propagate_on_container_swap | false_type propagate_on_container_swap; typedef Alloc::is_always_equal | is_empty is_always_equal; template using rebind_alloc = Alloc::rebind::other | Alloc; template using rebind_traits = allocator_traits>; static pointer allocate(allocator_type& a, size_type n); // constexpr and [[nodiscard]] in C++20 static pointer allocate(allocator_type& a, size_type n, const_void_pointer hint); // constexpr and [[nodiscard]] in C++20 [[nodiscard]] static constexpr allocation_result allocate_at_least(Alloc& a, size_type n); // Since C++23 static void deallocate(allocator_type& a, pointer p, size_type n) noexcept; // constexpr in C++20 template static void construct(allocator_type& a, T* p, Args&&... args); // constexpr in C++20 template static void destroy(allocator_type& a, T* p); // constexpr in C++20 static size_type max_size(const allocator_type& a); // noexcept in C++14, constexpr in C++20 static allocator_type select_on_container_copy_construction(const allocator_type& a); // constexpr in C++20 }; template struct allocation_result { Pointer ptr; SizeType count; }; // Since C++23 template <> class allocator // removed in C++20 { public: typedef void* pointer; typedef const void* const_pointer; typedef void value_type; template struct rebind {typedef allocator<_Up> other;}; }; template class allocator { public: typedef size_t size_type; typedef ptrdiff_t difference_type; typedef T* pointer; // deprecated in C++17, removed in C++20 typedef const T* const_pointer; // deprecated in C++17, removed in C++20 typedef typename add_lvalue_reference::type reference; // deprecated in C++17, removed in C++20 typedef typename add_lvalue_reference::type const_reference; // deprecated in C++17, removed in C++20 typedef T value_type; template struct rebind {typedef allocator other;}; // deprecated in C++17, removed in C++20 typedef true_type propagate_on_container_move_assignment; typedef true_type is_always_equal; // Deprecated in C++23, removed in C++26 constexpr allocator() noexcept; // constexpr in C++20 constexpr allocator(const allocator&) noexcept; // constexpr in C++20 template constexpr allocator(const allocator&) noexcept; // constexpr in C++20 ~allocator(); // constexpr in C++20 pointer address(reference x) const noexcept; // deprecated in C++17, removed in C++20 const_pointer address(const_reference x) const noexcept; // deprecated in C++17, removed in C++20 T* allocate(size_t n, const void* hint); // deprecated in C++17, removed in C++20 T* allocate(size_t n); // constexpr in C++20 void deallocate(T* p, size_t n) noexcept; // constexpr in C++20 size_type max_size() const noexcept; // deprecated in C++17, removed in C++20 template void construct(U* p, Args&&... args); // deprecated in C++17, removed in C++20 template void destroy(U* p); // deprecated in C++17, removed in C++20 }; template bool operator==(const allocator&, const allocator&) noexcept; // constexpr in C++20 template bool operator!=(const allocator&, const allocator&) noexcept; // removed in C++20 template class raw_storage_iterator // deprecated in C++17, removed in C++20 : public iterator // until C++17 { public: typedef output_iterator_tag iterator_category; typedef void value_type; typedef void difference_type; // until C++20 typedef ptrdiff_t difference_type; // since C++20 typedef void pointer; typedef void reference; explicit raw_storage_iterator(OutputIterator x); raw_storage_iterator& operator*(); raw_storage_iterator& operator=(const T& element); raw_storage_iterator& operator++(); raw_storage_iterator operator++(int); }; template pair get_temporary_buffer(ptrdiff_t n) noexcept; template void return_temporary_buffer(T* p) noexcept; template T* addressof(T& r) noexcept; template T* addressof(const T&& r) noexcept = delete; template ForwardIterator uninitialized_copy(InputIterator first, InputIterator last, ForwardIterator result); namespace ranges { template using uninitialized_copy_result = in_out_result; // since C++20 template Sentinel1, nothrow-forward-iterator OutputIterator, nothrow-sentinel-for Sentinel2> requires constructible_from, iter_reference_t> uninitialized_copy_result uninitialized_copy(InputIterator ifirst, Sentinel1 ilast, OutputIterator ofirst, Sentinel2 olast); // since C++20 template requires constructible_from, range_reference_t> uninitialized_copy_result, borrowed_iterator_t> uninitialized_copy(InputRange&& in_range, OutputRange&& out_range); // since C++20 } template ForwardIterator uninitialized_copy_n(InputIterator first, Size n, ForwardIterator result); namespace ranges { template using uninitialized_copy_n_result = in_out_result; // since C++20 template Sentinel> requires constructible_from, iter_reference_t> uninitialized_copy_n_result uninitialized_copy_n(InputIterator ifirst, iter_difference_t n, OutputIterator ofirst, Sentinel olast); // since C++20 } template void uninitialized_fill(ForwardIterator first, ForwardIterator last, const T& x); namespace ranges { template Sentinel, class T> requires constructible_from, const T&> ForwardIterator uninitialized_fill(ForwardIterator first, Sentinel last, const T& x); // since C++20 template requires constructible_from, const T&> borrowed_iterator_t uninitialized_fill(ForwardRange&& range, const T& x); // since C++20 } template ForwardIterator uninitialized_fill_n(ForwardIterator first, Size n, const T& x); namespace ranges { template requires constructible_from, const T&> ForwardIterator uninitialized_fill_n(ForwardIterator first, iter_difference_t n); // since C++20 } template constexpr T* construct_at(T* location, Args&& ...args); // since C++20 namespace ranges { template constexpr T* construct_at(T* location, Args&&... args); // since C++20 } template void destroy_at(T* location); // constexpr in C++20 namespace ranges { template constexpr void destroy_at(T* location) noexcept; // since C++20 } template void destroy(ForwardIterator first, ForwardIterator last); // constexpr in C++20 namespace ranges { template Sentinel> requires destructible> constexpr InputIterator destroy(InputIterator first, Sentinel last) noexcept; // since C++20 template requires destructible> constexpr borrowed_iterator_t destroy(InputRange&& range) noexcept; // since C++20 } template ForwardIterator destroy_n(ForwardIterator first, Size n); // constexpr in C++20 namespace ranges { template requires destructible> constexpr InputIterator destroy_n(InputIterator first, iter_difference_t n) noexcept; // since C++20 } template ForwardIterator uninitialized_move(InputIterator first, InputIterator last, ForwardIterator result); namespace ranges { template using uninitialized_move_result = in_out_result; // since C++20 template Sentinel1, nothrow-forward-iterator OutputIterator, nothrow-sentinel-for Sentinel2> requires constructible_from, iter_rvalue_reference_t> uninitialized_move_result uninitialized_move(InputIterator ifirst, Sentinel1 ilast, OutputIterator ofirst, Sentinel2 olast); // since C++20 template requires constructible_from, range_rvalue_reference_t> uninitialized_move_result, borrowed_iterator_t> uninitialized_move(InputRange&& in_range, OutputRange&& out_range); // since C++20 } template pair uninitialized_move_n(InputIterator first, Size n, ForwardIterator result); namespace ranges { template using uninitialized_move_n_result = in_out_result; // since C++20 template Sentinel> requires constructible_from, iter_rvalue_reference_t> uninitialized_move_n_result uninitialized_move_n(InputIterator ifirst, iter_difference_t n, OutputIterator ofirst, Sentinel olast); // since C++20 } template void uninitialized_value_construct(ForwardIterator first, ForwardIterator last); namespace ranges { template Sentinel> requires default_initializable> ForwardIterator uninitialized_value_construct(ForwardIterator first, Sentinel last); // since C++20 template requires default_initializable> borrowed_iterator_t uninitialized_value_construct(ForwardRange&& r); // since C++20 } template ForwardIterator uninitialized_value_construct_n(ForwardIterator first, Size n); namespace ranges { template requires default_initializable> ForwardIterator uninitialized_value_construct_n(ForwardIterator first, iter_difference_t n); // since C++20 } template void uninitialized_default_construct(ForwardIterator first, ForwardIterator last); namespace ranges { template Sentinel> requires default_initializable> ForwardIterator uninitialized_default_construct(ForwardIterator first, Sentinel last); // since C++20 template requires default_initializable> borrowed_iterator_t uninitialized_default_construct(ForwardRange&& r); // since C++20 } template ForwardIterator uninitialized_default_construct_n(ForwardIterator first, Size n); namespace ranges { template requires default_initializable> ForwardIterator uninitialized_default_construct_n(ForwardIterator first, iter_difference_t n); // since C++20 } template struct auto_ptr_ref {}; // deprecated in C++11, removed in C++17 template class auto_ptr // deprecated in C++11, removed in C++17 { public: typedef X element_type; explicit auto_ptr(X* p =0) throw(); auto_ptr(auto_ptr&) throw(); template auto_ptr(auto_ptr&) throw(); auto_ptr& operator=(auto_ptr&) throw(); template auto_ptr& operator=(auto_ptr&) throw(); auto_ptr& operator=(auto_ptr_ref r) throw(); ~auto_ptr() throw(); typename add_lvalue_reference::type operator*() const throw(); X* operator->() const throw(); X* get() const throw(); X* release() throw(); void reset(X* p =0) throw(); auto_ptr(auto_ptr_ref) throw(); template operator auto_ptr_ref() throw(); template operator auto_ptr() throw(); }; template struct default_delete { constexpr default_delete() noexcept = default; template constexpr default_delete(const default_delete&) noexcept; // constexpr since C++23 constexpr void operator()(T*) const noexcept; // constexpr since C++23 }; template struct default_delete { constexpr default_delete() noexcept = default; template constexpr default_delete(const default_delete &) noexcept; // constexpr since C++23 constexpr void operator()(T*) const noexcept; // constexpr since C++23 template void operator()(U*) const = delete; }; template > class unique_ptr { public: typedef see below pointer; typedef T element_type; typedef D deleter_type; // constructors constexpr unique_ptr() noexcept; constexpr explicit unique_ptr(pointer p) noexcept; // constexpr since C++23 constexpr unique_ptr(pointer p, see below d1) noexcept; // constexpr since C++23 constexpr unique_ptr(pointer p, see below d2) noexcept; // constexpr since C++23 constexpr unique_ptr(unique_ptr&& u) noexcept; // constexpr since C++23 constexpr unique_ptr(nullptr_t) noexcept : unique_ptr() { } template constexpr unique_ptr(unique_ptr&& u) noexcept; // constexpr since C++23 template unique_ptr(auto_ptr&& u) noexcept; // removed in C++17 // destructor constexpr ~unique_ptr(); // constexpr since C++23 // assignment constexpr unique_ptr& operator=(unique_ptr&& u) noexcept; // constexpr since C++23 template constexpr unique_ptr& operator=(unique_ptr&& u) noexcept; // constexpr since C++23 constexpr unique_ptr& operator=(nullptr_t) noexcept; // constexpr since C++23 // observers constexpr add_lvalue_reference::type operator*() const noexcept(see below); // constexpr since C++23 constexpr pointer operator->() const noexcept; // constexpr since C++23 constexpr pointer get() const noexcept; // constexpr since C++23 constexpr deleter_type& get_deleter() noexcept; // constexpr since C++23 constexpr const deleter_type& get_deleter() const noexcept; // constexpr since C++23 constexpr explicit operator bool() const noexcept; // constexpr since C++23 // modifiers constexpr pointer release() noexcept; // constexpr since C++23 constexpr void reset(pointer p = pointer()) noexcept; // constexpr since C++23 constexpr void swap(unique_ptr& u) noexcept; // constexpr since C++23 }; template class unique_ptr { public: typedef implementation-defined pointer; typedef T element_type; typedef D deleter_type; // constructors constexpr unique_ptr() noexcept; constexpr explicit unique_ptr(pointer p) noexcept; // constexpr since C++23 constexpr unique_ptr(pointer p, see below d) noexcept; // constexpr since C++23 constexpr unique_ptr(pointer p, see below d) noexcept; // constexpr since C++23 constexpr unique_ptr(unique_ptr&& u) noexcept; // constexpr since C++23 template constexpr unique_ptr(unique_ptr && u) noexcept; // constexpr since C++23 constexpr unique_ptr(nullptr_t) noexcept : unique_ptr() { } // destructor constexpr ~unique_ptr(); // constexpr since C++23 // assignment constexpr unique_ptr& operator=(unique_ptr&& u) noexcept; // constexpr since C++23 template constexpr unique_ptr& operator=(unique_ptr && u) noexcept; // constexpr since C++23 constexpr unique_ptr& operator=(nullptr_t) noexcept; // constexpr since C++23 // observers constexpr T& operator[](size_t i) const; // constexpr since C++23 constexpr pointer get() const noexcept; // constexpr since C++23 constexpr deleter_type& get_deleter() noexcept; // constexpr since C++23 constexpr const deleter_type& get_deleter() const noexcept; // constexpr since C++23 constexpr explicit operator bool() const noexcept; // constexpr since C++23 // modifiers constexpr pointer release() noexcept; // constexpr since C++23 constexpr void reset(pointer p = pointer()) noexcept; // constexpr since C++23 constexpr void reset(nullptr_t) noexcept; // constexpr since C++23 template void reset(U) = delete; constexpr void swap(unique_ptr& u) noexcept; // constexpr since C++23 }; template constexpr void swap(unique_ptr& x, unique_ptr& y) noexcept; // constexpr since C++23 template constexpr bool operator==(const unique_ptr& x, const unique_ptr& y); // constexpr since C++23 template bool operator!=(const unique_ptr& x, const unique_ptr& y); // removed in C++20 template bool operator<(const unique_ptr& x, const unique_ptr& y); template bool operator<=(const unique_ptr& x, const unique_ptr& y); template bool operator>(const unique_ptr& x, const unique_ptr& y); template bool operator>=(const unique_ptr& x, const unique_ptr& y); template requires three_way_comparable_with::pointer, typename unique_ptr::pointer> compare_three_way_result_t::pointer, typename unique_ptr::pointer> operator<=>(const unique_ptr& x, const unique_ptr& y); // C++20 template constexpr bool operator==(const unique_ptr& x, nullptr_t) noexcept; // constexpr since C++23 template bool operator==(nullptr_t, const unique_ptr& y) noexcept; // removed in C++20 template bool operator!=(const unique_ptr& x, nullptr_t) noexcept; // removed in C++20 template bool operator!=(nullptr_t, const unique_ptr& y) noexcept; // removed in C++20 template constexpr bool operator<(const unique_ptr& x, nullptr_t); // constexpr since C++23 template constexpr bool operator<(nullptr_t, const unique_ptr& y); // constexpr since C++23 template constexpr bool operator<=(const unique_ptr& x, nullptr_t); // constexpr since C++23 template constexpr bool operator<=(nullptr_t, const unique_ptr& y); // constexpr since C++23 template constexpr bool operator>(const unique_ptr& x, nullptr_t); // constexpr since C++23 template constexpr bool operator>(nullptr_t, const unique_ptr& y); // constexpr since C++23 template constexpr bool operator>=(const unique_ptr& x, nullptr_t); // constexpr since C++23 template constexpr bool operator>=(nullptr_t, const unique_ptr& y); // constexpr since C++23 template requires three_way_comparable::pointer> compare_three_way_result_t::pointer> constexpr operator<=>(const unique_ptr& x, nullptr_t); // C++20, constexpr since C++23 class bad_weak_ptr : public std::exception { bad_weak_ptr() noexcept; }; template constexpr unique_ptr make_unique(Args&&... args); // C++14, constexpr since C++23 template constexpr unique_ptr make_unique(size_t n); // C++14, constexpr since C++23 template unspecified make_unique(Args&&...) = delete; // C++14, T == U[N] template constexpr unique_ptr make_unique_for_overwrite(); // T is not array, C++20, constexpr since C++23 template constexpr unique_ptr make_unique_for_overwrite(size_t n); // T is U[], C++20, constexpr since C++23 template unspecified make_unique_for_overwrite(Args&&...) = delete; // T is U[N], C++20 template basic_ostream& operator<< (basic_ostream& os, unique_ptr const& p); template class shared_ptr { public: typedef T element_type; // until C++17 typedef remove_extent_t element_type; // since C++17 typedef weak_ptr weak_type; // C++17 // constructors: constexpr shared_ptr() noexcept; template explicit shared_ptr(Y* p); template shared_ptr(Y* p, D d); template shared_ptr(Y* p, D d, A a); template shared_ptr(nullptr_t p, D d); template shared_ptr(nullptr_t p, D d, A a); template shared_ptr(const shared_ptr& r, T *p) noexcept; shared_ptr(const shared_ptr& r) noexcept; template shared_ptr(const shared_ptr& r) noexcept; shared_ptr(shared_ptr&& r) noexcept; template shared_ptr(shared_ptr&& r) noexcept; template explicit shared_ptr(const weak_ptr& r); template shared_ptr(auto_ptr&& r); // removed in C++17 template shared_ptr(unique_ptr&& r); shared_ptr(nullptr_t) : shared_ptr() { } // destructor: ~shared_ptr(); // assignment: shared_ptr& operator=(const shared_ptr& r) noexcept; template shared_ptr& operator=(const shared_ptr& r) noexcept; shared_ptr& operator=(shared_ptr&& r) noexcept; template shared_ptr& operator=(shared_ptr&& r); template shared_ptr& operator=(auto_ptr&& r); // removed in C++17 template shared_ptr& operator=(unique_ptr&& r); // modifiers: void swap(shared_ptr& r) noexcept; void reset() noexcept; template void reset(Y* p); template void reset(Y* p, D d); template void reset(Y* p, D d, A a); // observers: T* get() const noexcept; T& operator*() const noexcept; T* operator->() const noexcept; long use_count() const noexcept; bool unique() const noexcept; // deprected in C++17, removed in C++20 explicit operator bool() const noexcept; template bool owner_before(shared_ptr const& b) const noexcept; template bool owner_before(weak_ptr const& b) const noexcept; }; template shared_ptr(weak_ptr) -> shared_ptr; template shared_ptr(unique_ptr) -> shared_ptr; // shared_ptr comparisons: template bool operator==(shared_ptr const& a, shared_ptr const& b) noexcept; template bool operator!=(shared_ptr const& a, shared_ptr const& b) noexcept; // removed in C++20 template bool operator<(shared_ptr const& a, shared_ptr const& b) noexcept; // removed in C++20 template bool operator>(shared_ptr const& a, shared_ptr const& b) noexcept; // removed in C++20 template bool operator<=(shared_ptr const& a, shared_ptr const& b) noexcept; // removed in C++20 template bool operator>=(shared_ptr const& a, shared_ptr const& b) noexcept; // removed in C++20 template strong_ordering operator<=>(shared_ptr const& a, shared_ptr const& b) noexcept; // C++20 template bool operator==(const shared_ptr& x, nullptr_t) noexcept; template bool operator==(nullptr_t, const shared_ptr& y) noexcept; // removed in C++20 template bool operator!=(const shared_ptr& x, nullptr_t) noexcept; // removed in C++20 template bool operator!=(nullptr_t, const shared_ptr& y) noexcept; // removed in C++20 template bool operator<(const shared_ptr& x, nullptr_t) noexcept; // removed in C++20 template bool operator<(nullptr_t, const shared_ptr& y) noexcept; // removed in C++20 template bool operator<=(const shared_ptr& x, nullptr_t) noexcept; // removed in C++20 template bool operator<=(nullptr_t, const shared_ptr& y) noexcept; // removed in C++20 template bool operator>(const shared_ptr& x, nullptr_t) noexcept; // removed in C++20 template bool operator>(nullptr_t, const shared_ptr& y) noexcept; // removed in C++20 template bool operator>=(const shared_ptr& x, nullptr_t) noexcept; // removed in C++20 template bool operator>=(nullptr_t, const shared_ptr& y) noexcept; // removed in C++20 template strong_ordering operator<=>(shared_ptr const& x, nullptr_t) noexcept; // C++20 // shared_ptr specialized algorithms: template void swap(shared_ptr& a, shared_ptr& b) noexcept; // shared_ptr casts: template shared_ptr static_pointer_cast(shared_ptr const& r) noexcept; template shared_ptr dynamic_pointer_cast(shared_ptr const& r) noexcept; template shared_ptr const_pointer_cast(shared_ptr const& r) noexcept; // shared_ptr I/O: template basic_ostream& operator<< (basic_ostream& os, shared_ptr const& p); // shared_ptr get_deleter: template D* get_deleter(shared_ptr const& p) noexcept; template shared_ptr make_shared(Args&&... args); // T is not an array template shared_ptr allocate_shared(const A& a, Args&&... args); // T is not an array template shared_ptr make_shared(size_t N); // T is U[] (since C++20) template shared_ptr allocate_shared(const A& a, size_t N); // T is U[] (since C++20) template shared_ptr make_shared(); // T is U[N] (since C++20) template shared_ptr allocate_shared(const A& a); // T is U[N] (since C++20) template shared_ptr make_shared(size_t N, const remove_extent_t& u); // T is U[] (since C++20) template shared_ptr allocate_shared(const A& a, size_t N, const remove_extent_t& u); // T is U[] (since C++20) template shared_ptr make_shared(const remove_extent_t& u); // T is U[N] (since C++20) template shared_ptr allocate_shared(const A& a, const remove_extent_t& u); // T is U[N] (since C++20) template shared_ptr make_shared_for_overwrite(); // T is not U[], C++20 template shared_ptr allocate_shared_for_overwrite(const A& a); // T is not U[], C++20 template shared_ptr make_shared_for_overwrite(size_t N); // T is U[], C++20 template shared_ptr allocate_shared_for_overwrite(const A& a, size_t N); // T is U[], C++20 template class weak_ptr { public: typedef T element_type; // until C++17 typedef remove_extent_t element_type; // since C++17 // constructors constexpr weak_ptr() noexcept; template weak_ptr(shared_ptr const& r) noexcept; weak_ptr(weak_ptr const& r) noexcept; template weak_ptr(weak_ptr const& r) noexcept; weak_ptr(weak_ptr&& r) noexcept; // C++14 template weak_ptr(weak_ptr&& r) noexcept; // C++14 // destructor ~weak_ptr(); // assignment weak_ptr& operator=(weak_ptr const& r) noexcept; template weak_ptr& operator=(weak_ptr const& r) noexcept; template weak_ptr& operator=(shared_ptr const& r) noexcept; weak_ptr& operator=(weak_ptr&& r) noexcept; // C++14 template weak_ptr& operator=(weak_ptr&& r) noexcept; // C++14 // modifiers void swap(weak_ptr& r) noexcept; void reset() noexcept; // observers long use_count() const noexcept; bool expired() const noexcept; shared_ptr lock() const noexcept; template bool owner_before(shared_ptr const& b) const noexcept; template bool owner_before(weak_ptr const& b) const noexcept; }; template weak_ptr(shared_ptr) -> weak_ptr; // weak_ptr specialized algorithms: template void swap(weak_ptr& a, weak_ptr& b) noexcept; // class owner_less: template struct owner_less; template struct owner_less > : binary_function, shared_ptr, bool> { typedef bool result_type; bool operator()(shared_ptr const&, shared_ptr const&) const noexcept; bool operator()(shared_ptr const&, weak_ptr const&) const noexcept; bool operator()(weak_ptr const&, shared_ptr const&) const noexcept; }; template struct owner_less > : binary_function, weak_ptr, bool> { typedef bool result_type; bool operator()(weak_ptr const&, weak_ptr const&) const noexcept; bool operator()(shared_ptr const&, weak_ptr const&) const noexcept; bool operator()(weak_ptr const&, shared_ptr const&) const noexcept; }; template <> // Added in C++14 struct owner_less { template bool operator()( shared_ptr<_Tp> const& __x, shared_ptr<_Up> const& __y) const noexcept; template bool operator()( shared_ptr<_Tp> const& __x, weak_ptr<_Up> const& __y) const noexcept; template bool operator()( weak_ptr<_Tp> const& __x, shared_ptr<_Up> const& __y) const noexcept; template bool operator()( weak_ptr<_Tp> const& __x, weak_ptr<_Up> const& __y) const noexcept; typedef void is_transparent; }; template class enable_shared_from_this { protected: constexpr enable_shared_from_this() noexcept; enable_shared_from_this(enable_shared_from_this const&) noexcept; enable_shared_from_this& operator=(enable_shared_from_this const&) noexcept; ~enable_shared_from_this(); public: shared_ptr shared_from_this(); shared_ptr shared_from_this() const; }; template bool atomic_is_lock_free(const shared_ptr* p); template shared_ptr atomic_load(const shared_ptr* p); template shared_ptr atomic_load_explicit(const shared_ptr* p, memory_order mo); template void atomic_store(shared_ptr* p, shared_ptr r); template void atomic_store_explicit(shared_ptr* p, shared_ptr r, memory_order mo); template shared_ptr atomic_exchange(shared_ptr* p, shared_ptr r); template shared_ptr atomic_exchange_explicit(shared_ptr* p, shared_ptr r, memory_order mo); template bool atomic_compare_exchange_weak(shared_ptr* p, shared_ptr* v, shared_ptr w); template bool atomic_compare_exchange_strong( shared_ptr* p, shared_ptr* v, shared_ptr w); template bool atomic_compare_exchange_weak_explicit(shared_ptr* p, shared_ptr* v, shared_ptr w, memory_order success, memory_order failure); template bool atomic_compare_exchange_strong_explicit(shared_ptr* p, shared_ptr* v, shared_ptr w, memory_order success, memory_order failure); // Hash support template struct hash; template struct hash >; template struct hash >; template inline constexpr bool uses_allocator_v = uses_allocator::value; // [allocator.uses.construction], uses-allocator construction template constexpr auto uses_allocator_construction_args(const Alloc& alloc, // since C++20 Args&&... args) noexcept; template constexpr auto uses_allocator_construction_args(const Alloc& alloc, // since C++20 piecewise_construct_t, Tuple1&& x, Tuple2&& y) noexcept; template constexpr auto uses_allocator_construction_args(const Alloc& alloc) noexcept; // since C++20 template constexpr auto uses_allocator_construction_args(const Alloc& alloc, // since C++20 U&& u, V&& v) noexcept; template constexpr auto uses_allocator_construction_args(const Alloc& alloc, // since C++23 pair& pr) noexcept; template constexpr auto uses_allocator_construction_args(const Alloc& alloc, // since C++20 const pair& pr) noexcept; template constexpr auto uses_allocator_construction_args(const Alloc& alloc, // since C++20 pair&& pr) noexcept; template constexpr auto uses_allocator_construction_args(const Alloc& alloc, // since C++23 const pair&& pr) noexcept; template constexpr auto uses_allocator_construction_args(const Alloc& alloc, // since C++20 P&& p) noexcept; template constexpr auto uses_allocator_construction_args(const Alloc& alloc, // since C++20 U&& u) noexcept; template constexpr T make_obj_using_allocator(const Alloc& alloc, Args&&... args); // since C++20 template constexpr T* uninitialized_construct_using_allocator(T* p, // since C++20 const Alloc& alloc, Args&&... args); // [ptr.align] void* align(size_t alignment, size_t size, void*& ptr, size_t& space); template [[nodiscard]] constexpr T* assume_aligned(T* ptr); // since C++20 // [out.ptr.t], class template out_ptr_t template class out_ptr_t; // since c++23 // [out.ptr], function template out_ptr template auto out_ptr(Smart& s, Args&&... args); // since c++23 // [inout.ptr.t], class template inout_ptr_t template class inout_ptr_t; // since c++23 // [inout.ptr], function template inout_ptr template auto inout_ptr(Smart& s, Args&&... args); // since c++23 } // std */ // clang-format on #include <__config> #include <__memory/addressof.h> #include <__memory/align.h> #include <__memory/allocator.h> #include <__memory/allocator_arg_t.h> #include <__memory/allocator_traits.h> #include <__memory/auto_ptr.h> #include <__memory/inout_ptr.h> #include <__memory/out_ptr.h> #include <__memory/pointer_traits.h> #include <__memory/raw_storage_iterator.h> #include <__memory/shared_ptr.h> #include <__memory/temporary_buffer.h> #include <__memory/uninitialized_algorithms.h> #include <__memory/unique_ptr.h> #include <__memory/uses_allocator.h> // standard-mandated includes #if _LIBCPP_STD_VER >= 17 # include <__memory/construct_at.h> #endif #if _LIBCPP_STD_VER >= 20 # include <__memory/assume_aligned.h> # include <__memory/concepts.h> # include <__memory/ranges_construct_at.h> # include <__memory/ranges_uninitialized_algorithms.h> # include <__memory/uses_allocator_construction.h> #endif #if _LIBCPP_STD_VER >= 23 # include <__memory/allocate_at_least.h> #endif #include // [memory.syn] #include #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) # pragma GCC system_header #endif #if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 # include # include # include # include # include # include # include # include # include # include # include # include # include # include #endif #endif // _LIBCPP_MEMORY