10b57cec5SDimitry Andric// -*- C++ -*-
2349cc55cSDimitry Andric//===----------------------------------------------------------------------===//
30b57cec5SDimitry Andric//
40b57cec5SDimitry Andric// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
50b57cec5SDimitry Andric// See https://llvm.org/LICENSE.txt for license information.
60b57cec5SDimitry Andric// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
70b57cec5SDimitry Andric//
80b57cec5SDimitry Andric//===----------------------------------------------------------------------===//
90b57cec5SDimitry Andric
100b57cec5SDimitry Andric#ifndef _LIBCPP_MEMORY
110b57cec5SDimitry Andric#define _LIBCPP_MEMORY
120b57cec5SDimitry Andric
135f757f3fSDimitry Andric// clang-format off
145f757f3fSDimitry Andric
150b57cec5SDimitry Andric/*
160b57cec5SDimitry Andric    memory synopsis
170b57cec5SDimitry Andric
180b57cec5SDimitry Andricnamespace std
190b57cec5SDimitry Andric{
200b57cec5SDimitry Andric
210b57cec5SDimitry Andricstruct allocator_arg_t { };
220b57cec5SDimitry Andricinline constexpr allocator_arg_t allocator_arg = allocator_arg_t();
230b57cec5SDimitry Andric
240b57cec5SDimitry Andrictemplate <class T, class Alloc> struct uses_allocator;
250b57cec5SDimitry Andric
260b57cec5SDimitry Andrictemplate <class Ptr>
270b57cec5SDimitry Andricstruct pointer_traits
280b57cec5SDimitry Andric{
290b57cec5SDimitry Andric    typedef Ptr pointer;
300b57cec5SDimitry Andric    typedef <details> element_type;
310b57cec5SDimitry Andric    typedef <details> difference_type;
320b57cec5SDimitry Andric
330b57cec5SDimitry Andric    template <class U> using rebind = <details>;
340b57cec5SDimitry Andric
350b57cec5SDimitry Andric    static pointer pointer_to(<details>);
360b57cec5SDimitry Andric};
370b57cec5SDimitry Andric
380b57cec5SDimitry Andrictemplate <class T>
390b57cec5SDimitry Andricstruct pointer_traits<T*>
400b57cec5SDimitry Andric{
410b57cec5SDimitry Andric    typedef T* pointer;
420b57cec5SDimitry Andric    typedef T element_type;
430b57cec5SDimitry Andric    typedef ptrdiff_t difference_type;
440b57cec5SDimitry Andric
450b57cec5SDimitry Andric    template <class U> using rebind = U*;
460b57cec5SDimitry Andric
470b57cec5SDimitry Andric    static pointer pointer_to(<details>) noexcept; // constexpr in C++20
480b57cec5SDimitry Andric};
490b57cec5SDimitry Andric
500b57cec5SDimitry Andrictemplate <class T> constexpr T* to_address(T* p) noexcept; // C++20
51e8d8bef9SDimitry Andrictemplate <class Ptr> constexpr auto to_address(const Ptr& p) noexcept; // C++20
520b57cec5SDimitry Andric
530b57cec5SDimitry Andrictemplate <class Alloc>
540b57cec5SDimitry Andricstruct allocator_traits
550b57cec5SDimitry Andric{
560b57cec5SDimitry Andric    typedef Alloc                        allocator_type;
570b57cec5SDimitry Andric    typedef typename allocator_type::value_type
580b57cec5SDimitry Andric                                         value_type;
590b57cec5SDimitry Andric
600b57cec5SDimitry Andric    typedef Alloc::pointer | value_type* pointer;
610b57cec5SDimitry Andric    typedef Alloc::const_pointer
620b57cec5SDimitry Andric          | pointer_traits<pointer>::rebind<const value_type>
630b57cec5SDimitry Andric                                         const_pointer;
640b57cec5SDimitry Andric    typedef Alloc::void_pointer
650b57cec5SDimitry Andric          | pointer_traits<pointer>::rebind<void>
660b57cec5SDimitry Andric                                         void_pointer;
670b57cec5SDimitry Andric    typedef Alloc::const_void_pointer
680b57cec5SDimitry Andric          | pointer_traits<pointer>::rebind<const void>
690b57cec5SDimitry Andric                                         const_void_pointer;
700b57cec5SDimitry Andric    typedef Alloc::difference_type
710b57cec5SDimitry Andric          | pointer_traits<pointer>::difference_type
720b57cec5SDimitry Andric                                         difference_type;
730b57cec5SDimitry Andric    typedef Alloc::size_type
740b57cec5SDimitry Andric          | make_unsigned<difference_type>::type
750b57cec5SDimitry Andric                                         size_type;
760b57cec5SDimitry Andric    typedef Alloc::propagate_on_container_copy_assignment
770b57cec5SDimitry Andric          | false_type                   propagate_on_container_copy_assignment;
780b57cec5SDimitry Andric    typedef Alloc::propagate_on_container_move_assignment
790b57cec5SDimitry Andric          | false_type                   propagate_on_container_move_assignment;
800b57cec5SDimitry Andric    typedef Alloc::propagate_on_container_swap
810b57cec5SDimitry Andric          | false_type                   propagate_on_container_swap;
820b57cec5SDimitry Andric    typedef Alloc::is_always_equal
830b57cec5SDimitry Andric          | is_empty                     is_always_equal;
840b57cec5SDimitry Andric
855ffd83dbSDimitry Andric    template <class T> using rebind_alloc  = Alloc::rebind<T>::other | Alloc<T, Args...>;
860b57cec5SDimitry Andric    template <class T> using rebind_traits = allocator_traits<rebind_alloc<T>>;
870b57cec5SDimitry Andric
88e8d8bef9SDimitry Andric    static pointer allocate(allocator_type& a, size_type n);                          // constexpr and [[nodiscard]] in C++20
89e8d8bef9SDimitry Andric    static pointer allocate(allocator_type& a, size_type n, const_void_pointer hint); // constexpr and [[nodiscard]] in C++20
900b57cec5SDimitry Andric
91e8d8bef9SDimitry Andric    static void deallocate(allocator_type& a, pointer p, size_type n) noexcept; // constexpr in C++20
920b57cec5SDimitry Andric
930b57cec5SDimitry Andric    template <class T, class... Args>
94e8d8bef9SDimitry Andric    static void construct(allocator_type& a, T* p, Args&&... args); // constexpr in C++20
950b57cec5SDimitry Andric
960b57cec5SDimitry Andric    template <class T>
97e8d8bef9SDimitry Andric    static void destroy(allocator_type& a, T* p); // constexpr in C++20
980b57cec5SDimitry Andric
99e8d8bef9SDimitry Andric    static size_type max_size(const allocator_type& a); // noexcept in C++14, constexpr in C++20
100e8d8bef9SDimitry Andric    static allocator_type select_on_container_copy_construction(const allocator_type& a); // constexpr in C++20
1010b57cec5SDimitry Andric};
1020b57cec5SDimitry Andric
10381ad6265SDimitry Andrictemplate<class Pointer>
10481ad6265SDimitry Andricstruct allocation_result {
10581ad6265SDimitry Andric    Pointer ptr;
10681ad6265SDimitry Andric    size_t count;
10781ad6265SDimitry Andric}; // since C++23
10881ad6265SDimitry Andric
10981ad6265SDimitry Andrictemplate<class Allocator>
11081ad6265SDimitry Andric[[nodiscard]] constexpr allocation_result<typename allocator_traits<Allocator>::pointer>
11181ad6265SDimitry Andric    allocate_at_least(Allocator& a, size_t n); // since C++23
11281ad6265SDimitry Andric
1130b57cec5SDimitry Andrictemplate <>
11423408297SDimitry Andricclass allocator<void> // removed in C++20
1150b57cec5SDimitry Andric{
1160b57cec5SDimitry Andricpublic:
117fe6060f1SDimitry Andric    typedef void*                                 pointer;
118fe6060f1SDimitry Andric    typedef const void*                           const_pointer;
119fe6060f1SDimitry Andric    typedef void                                  value_type;
1200b57cec5SDimitry Andric
121fe6060f1SDimitry Andric    template <class _Up> struct rebind {typedef allocator<_Up> other;};
1220b57cec5SDimitry Andric};
1230b57cec5SDimitry Andric
1240b57cec5SDimitry Andrictemplate <class T>
1250b57cec5SDimitry Andricclass allocator
1260b57cec5SDimitry Andric{
1270b57cec5SDimitry Andricpublic:
128e8d8bef9SDimitry Andric    typedef size_t    size_type;
129e8d8bef9SDimitry Andric    typedef ptrdiff_t difference_type;
1305ffd83dbSDimitry Andric    typedef T*        pointer;                           // deprecated in C++17, removed in C++20
1315ffd83dbSDimitry Andric    typedef const T*  const_pointer;                     // deprecated in C++17, removed in C++20
1325ffd83dbSDimitry Andric    typedef typename add_lvalue_reference<T>::type
1335ffd83dbSDimitry Andric                      reference;                         // deprecated in C++17, removed in C++20
1345ffd83dbSDimitry Andric    typedef typename add_lvalue_reference<const T>::type
1355ffd83dbSDimitry Andric                      const_reference;                   // deprecated in C++17, removed in C++20
1365ffd83dbSDimitry Andric
1370b57cec5SDimitry Andric    typedef T         value_type;
1380b57cec5SDimitry Andric
1395ffd83dbSDimitry Andric    template <class U> struct rebind {typedef allocator<U> other;}; // deprecated in C++17, removed in C++20
1405ffd83dbSDimitry Andric
1415ffd83dbSDimitry Andric    typedef true_type propagate_on_container_move_assignment;
1427a6dacacSDimitry Andric    typedef true_type is_always_equal;                   // Deprecated in C++23, removed in C++26
1430b57cec5SDimitry Andric
1440b57cec5SDimitry Andric    constexpr allocator() noexcept;                      // constexpr in C++20
1450b57cec5SDimitry Andric    constexpr allocator(const allocator&) noexcept;      // constexpr in C++20
1460b57cec5SDimitry Andric    template <class U>
1470b57cec5SDimitry Andric      constexpr allocator(const allocator<U>&) noexcept; // constexpr in C++20
148e8d8bef9SDimitry Andric    ~allocator();                                        // constexpr in C++20
1495ffd83dbSDimitry Andric    pointer address(reference x) const noexcept;             // deprecated in C++17, removed in C++20
1505ffd83dbSDimitry Andric    const_pointer address(const_reference x) const noexcept; // deprecated in C++17, removed in C++20
1515ffd83dbSDimitry Andric    T* allocate(size_t n, const void* hint);          // deprecated in C++17, removed in C++20
152e8d8bef9SDimitry Andric    T* allocate(size_t n);                              // constexpr in C++20
153e8d8bef9SDimitry Andric    void deallocate(T* p, size_t n) noexcept;           // constexpr in C++20
1545ffd83dbSDimitry Andric    size_type max_size() const noexcept;              // deprecated in C++17, removed in C++20
1550b57cec5SDimitry Andric    template<class U, class... Args>
1565ffd83dbSDimitry Andric        void construct(U* p, Args&&... args);         // deprecated in C++17, removed in C++20
1570b57cec5SDimitry Andric    template <class U>
1585ffd83dbSDimitry Andric        void destroy(U* p);                           // deprecated in C++17, removed in C++20
1590b57cec5SDimitry Andric};
1600b57cec5SDimitry Andric
1610b57cec5SDimitry Andrictemplate <class T, class U>
162e8d8bef9SDimitry Andricbool operator==(const allocator<T>&, const allocator<U>&) noexcept; // constexpr in C++20
1630b57cec5SDimitry Andric
1640b57cec5SDimitry Andrictemplate <class T, class U>
16506c3fb27SDimitry Andricbool operator!=(const allocator<T>&, const allocator<U>&) noexcept; // removed in C++20
1660b57cec5SDimitry Andric
1670b57cec5SDimitry Andrictemplate <class OutputIterator, class T>
168fe6060f1SDimitry Andricclass raw_storage_iterator // deprecated in C++17, removed in C++20
169fe6060f1SDimitry Andric    : public iterator<output_iterator_tag, void, void, void, void> // until C++17
1700b57cec5SDimitry Andric{
1710b57cec5SDimitry Andricpublic:
172fe6060f1SDimitry Andric    typedef output_iterator_tag iterator_category;
173fe6060f1SDimitry Andric    typedef void                value_type;
174fe6060f1SDimitry Andric    typedef void                difference_type; // until C++20
175fe6060f1SDimitry Andric    typedef ptrdiff_t           difference_type; // since C++20
176fe6060f1SDimitry Andric    typedef void                pointer;
177fe6060f1SDimitry Andric    typedef void                reference;
178fe6060f1SDimitry Andric
1790b57cec5SDimitry Andric    explicit raw_storage_iterator(OutputIterator x);
1800b57cec5SDimitry Andric    raw_storage_iterator& operator*();
1810b57cec5SDimitry Andric    raw_storage_iterator& operator=(const T& element);
1820b57cec5SDimitry Andric    raw_storage_iterator& operator++();
1830b57cec5SDimitry Andric    raw_storage_iterator  operator++(int);
1840b57cec5SDimitry Andric};
1850b57cec5SDimitry Andric
1860b57cec5SDimitry Andrictemplate <class T> pair<T*,ptrdiff_t> get_temporary_buffer(ptrdiff_t n) noexcept;
1870b57cec5SDimitry Andrictemplate <class T> void               return_temporary_buffer(T* p) noexcept;
1880b57cec5SDimitry Andric
1890b57cec5SDimitry Andrictemplate <class T> T* addressof(T& r) noexcept;
1900b57cec5SDimitry Andrictemplate <class T> T* addressof(const T&& r) noexcept = delete;
1910b57cec5SDimitry Andric
1920b57cec5SDimitry Andrictemplate <class InputIterator, class ForwardIterator>
1930b57cec5SDimitry AndricForwardIterator
1940b57cec5SDimitry Andricuninitialized_copy(InputIterator first, InputIterator last, ForwardIterator result);
1950b57cec5SDimitry Andric
19604eeddc0SDimitry Andricnamespace ranges {
19704eeddc0SDimitry Andric
19804eeddc0SDimitry Andrictemplate<class InputIterator, class OutputIterator>
19904eeddc0SDimitry Andricusing uninitialized_copy_result = in_out_result<InputIterator, OutputIterator>; // since C++20
20004eeddc0SDimitry Andric
20104eeddc0SDimitry Andrictemplate<input_iterator InputIterator, sentinel-for<InputIterator> Sentinel1, nothrow-forward-iterator OutputIterator, nothrow-sentinel-for<OutputIterator> Sentinel2>
20204eeddc0SDimitry Andric  requires constructible_from<iter_value_t<OutputIterator>, iter_reference_t<InputIterator>>
20304eeddc0SDimitry Andricuninitialized_copy_result<InputIterator, OutputIterator>
20404eeddc0SDimitry Andricuninitialized_copy(InputIterator ifirst, Sentinel1 ilast, OutputIterator ofirst, Sentinel2 olast); // since C++20
20504eeddc0SDimitry Andric
20604eeddc0SDimitry Andrictemplate<input_range InputRange, nothrow-forward-range OutputRange>
20704eeddc0SDimitry Andric  requires constructible_from<range_value_t<OutputRange>, range_reference_t<InputRange>>
20804eeddc0SDimitry Andricuninitialized_copy_result<borrowed_iterator_t<InputRange>, borrowed_iterator_t<OutputRange>>
20904eeddc0SDimitry Andricuninitialized_copy(InputRange&& in_range, OutputRange&& out_range); // since C++20
21004eeddc0SDimitry Andric
21104eeddc0SDimitry Andric}
21204eeddc0SDimitry Andric
2130b57cec5SDimitry Andrictemplate <class InputIterator, class Size, class ForwardIterator>
2140b57cec5SDimitry AndricForwardIterator
2150b57cec5SDimitry Andricuninitialized_copy_n(InputIterator first, Size n, ForwardIterator result);
2160b57cec5SDimitry Andric
21704eeddc0SDimitry Andricnamespace ranges {
21804eeddc0SDimitry Andric
21904eeddc0SDimitry Andrictemplate<class InputIterator, class OutputIterator>
22004eeddc0SDimitry Andricusing uninitialized_copy_n_result = in_out_result<InputIterator, OutputIterator>; // since C++20
22104eeddc0SDimitry Andric
22204eeddc0SDimitry Andrictemplate<input_iterator InputIterator, nothrow-forward-iterator OutputIterator, nothrow-sentinel-for<OutputIterator> Sentinel>
22304eeddc0SDimitry Andric  requires constructible_from<iter_value_t<OutputIterator>, iter_reference_t<InputIterator>>
22404eeddc0SDimitry Andricuninitialized_copy_n_result<InputIterator, OutputIterator>
22504eeddc0SDimitry Andricuninitialized_copy_n(InputIterator ifirst, iter_difference_t<InputIterator> n, OutputIterator ofirst, Sentinel olast); // since C++20
22604eeddc0SDimitry Andric
22704eeddc0SDimitry Andric}
22804eeddc0SDimitry Andric
2290b57cec5SDimitry Andrictemplate <class ForwardIterator, class T>
2300b57cec5SDimitry Andricvoid uninitialized_fill(ForwardIterator first, ForwardIterator last, const T& x);
2310b57cec5SDimitry Andric
23204eeddc0SDimitry Andricnamespace ranges {
23304eeddc0SDimitry Andric
2340eae32dcSDimitry Andrictemplate <nothrow-forward-iterator ForwardIterator, nothrow-sentinel-for<ForwardIterator> Sentinel, class T>
2350eae32dcSDimitry Andric  requires constructible_from<iter_value_t<ForwardIterator>, const T&>
23604eeddc0SDimitry AndricForwardIterator uninitialized_fill(ForwardIterator first, Sentinel last, const T& x); // since C++20
2370eae32dcSDimitry Andric
2380eae32dcSDimitry Andrictemplate <nothrow-forward-range ForwardRange, class T>
2390eae32dcSDimitry Andric  requires constructible_from<range_value_t<ForwardRange>, const T&>
24004eeddc0SDimitry Andricborrowed_iterator_t<ForwardRange> uninitialized_fill(ForwardRange&& range, const T& x); // since C++20
24104eeddc0SDimitry Andric
24204eeddc0SDimitry Andric}
2430eae32dcSDimitry Andric
2440b57cec5SDimitry Andrictemplate <class ForwardIterator, class Size, class T>
2450b57cec5SDimitry AndricForwardIterator
2460b57cec5SDimitry Andricuninitialized_fill_n(ForwardIterator first, Size n, const T& x);
2470b57cec5SDimitry Andric
24804eeddc0SDimitry Andricnamespace ranges {
24904eeddc0SDimitry Andric
2500eae32dcSDimitry Andrictemplate <nothrow-forward-iterator ForwardIterator, class T>
2510eae32dcSDimitry Andric  requires constructible_from<iter_value_t<ForwardIterator>, const T&>
25204eeddc0SDimitry AndricForwardIterator uninitialized_fill_n(ForwardIterator first, iter_difference_t<ForwardIterator> n); // since C++20
25304eeddc0SDimitry Andric
25404eeddc0SDimitry Andric}
2550eae32dcSDimitry Andric
256e8d8bef9SDimitry Andrictemplate <class T, class ...Args>
257e8d8bef9SDimitry Andricconstexpr T* construct_at(T* location, Args&& ...args); // since C++20
258e8d8bef9SDimitry Andric
25904eeddc0SDimitry Andricnamespace ranges {
26004eeddc0SDimitry Andric  template<class T, class... Args>
26104eeddc0SDimitry Andric    constexpr T* construct_at(T* location, Args&&... args); // since C++20
26204eeddc0SDimitry Andric}
26304eeddc0SDimitry Andric
2640b57cec5SDimitry Andrictemplate <class T>
265e8d8bef9SDimitry Andricvoid destroy_at(T* location); // constexpr in C++20
2660b57cec5SDimitry Andric
26704eeddc0SDimitry Andricnamespace ranges {
26804eeddc0SDimitry Andric  template<destructible T>
26904eeddc0SDimitry Andric    constexpr void destroy_at(T* location) noexcept; // since C++20
27004eeddc0SDimitry Andric}
27104eeddc0SDimitry Andric
2720b57cec5SDimitry Andrictemplate <class ForwardIterator>
273e8d8bef9SDimitry Andricvoid destroy(ForwardIterator first, ForwardIterator last); // constexpr in C++20
2740b57cec5SDimitry Andric
27504eeddc0SDimitry Andricnamespace ranges {
27604eeddc0SDimitry Andric  template<nothrow-input-iterator InputIterator, nothrow-sentinel-for<InputIterator> Sentinel>
27704eeddc0SDimitry Andric    requires destructible<iter_value_t<InputIterator>>
27804eeddc0SDimitry Andric    constexpr InputIterator destroy(InputIterator first, Sentinel last) noexcept; // since C++20
27904eeddc0SDimitry Andric  template<nothrow-input-range InputRange>
28004eeddc0SDimitry Andric    requires destructible<range_value_t<InputRange>>
28104eeddc0SDimitry Andric    constexpr borrowed_iterator_t<InputRange> destroy(InputRange&& range) noexcept; // since C++20
28204eeddc0SDimitry Andric}
28304eeddc0SDimitry Andric
2840b57cec5SDimitry Andrictemplate <class ForwardIterator, class Size>
285e8d8bef9SDimitry AndricForwardIterator destroy_n(ForwardIterator first, Size n); // constexpr in C++20
2860b57cec5SDimitry Andric
28704eeddc0SDimitry Andricnamespace ranges {
28804eeddc0SDimitry Andric  template<nothrow-input-iterator InputIterator>
28904eeddc0SDimitry Andric    requires destructible<iter_value_t<InputIterator>>
29004eeddc0SDimitry Andric    constexpr InputIterator destroy_n(InputIterator first, iter_difference_t<InputIterator> n) noexcept; // since C++20
29104eeddc0SDimitry Andric}
29204eeddc0SDimitry Andric
2930b57cec5SDimitry Andrictemplate <class InputIterator, class ForwardIterator>
2940b57cec5SDimitry Andric ForwardIterator uninitialized_move(InputIterator first, InputIterator last, ForwardIterator result);
2950b57cec5SDimitry Andric
29604eeddc0SDimitry Andricnamespace ranges {
29704eeddc0SDimitry Andric
29804eeddc0SDimitry Andrictemplate<class InputIterator, class OutputIterator>
29904eeddc0SDimitry Andricusing uninitialized_move_result = in_out_result<InputIterator, OutputIterator>; // since C++20
30004eeddc0SDimitry Andric
30104eeddc0SDimitry Andrictemplate <input_iterator InputIterator, sentinel_for<InputIterator> Sentinel1, nothrow-forward-iterator OutputIterator, nothrow-sentinel-for<O> Sentinel2>
30204eeddc0SDimitry Andric  requires constructible_from<iter_value_t<OutputIterator>, iter_rvalue_reference_t<InputIterator>>
30304eeddc0SDimitry Andricuninitialized_move_result<InputIterator, OutputIterator>
30404eeddc0SDimitry Andricuninitialized_move(InputIterator ifirst, Sentinel1 ilast, OutputIterator ofirst, Sentinel2 olast); // since C++20
30504eeddc0SDimitry Andric
30604eeddc0SDimitry Andrictemplate<input_range InputRange, nothrow-forward-range OutputRange>
30704eeddc0SDimitry Andric  requires constructible_from<range_value_t<OutputRange>, range_rvalue_reference_t<InputRange>>
30804eeddc0SDimitry Andricuninitialized_move_result<borrowed_iterator_t<InputRange>, borrowed_iterator_t<OutputRange>>
30904eeddc0SDimitry Andricuninitialized_move(InputRange&& in_range, OutputRange&& out_range); // since C++20
31004eeddc0SDimitry Andric
31104eeddc0SDimitry Andric}
31204eeddc0SDimitry Andric
3130b57cec5SDimitry Andrictemplate <class InputIterator, class Size, class ForwardIterator>
3140b57cec5SDimitry Andric pair<InputIterator,ForwardIterator> uninitialized_move_n(InputIterator first, Size n, ForwardIterator result);
3150b57cec5SDimitry Andric
31604eeddc0SDimitry Andricnamespace ranges {
31704eeddc0SDimitry Andric
31804eeddc0SDimitry Andrictemplate<class InputIterator, class OutputIterator>
31904eeddc0SDimitry Andricusing uninitialized_move_n_result = in_out_result<InputIterator, OutputIterator>; // since C++20
32004eeddc0SDimitry Andric
32104eeddc0SDimitry Andrictemplate<input_iterator InputIterator, nothrow-forward-iterator OutputIterator, nothrow-sentinel-for<OutputIterator> Sentinel>
32204eeddc0SDimitry Andric  requires constructible_from<iter_value_t<OutputIterator>, iter_rvalue_reference_t<InputIterator>>
32304eeddc0SDimitry Andricuninitialized_move_n_result<InputIterator, OutputIterator>
32404eeddc0SDimitry Andricuninitialized_move_n(InputIterator ifirst, iter_difference_t<InputIterator> n, OutputIterator ofirst, Sentinel olast); // since C++20
32504eeddc0SDimitry Andric
32604eeddc0SDimitry Andric}
32704eeddc0SDimitry Andric
3280b57cec5SDimitry Andrictemplate <class ForwardIterator>
3290b57cec5SDimitry Andric void uninitialized_value_construct(ForwardIterator first, ForwardIterator last);
3300b57cec5SDimitry Andric
33104eeddc0SDimitry Andricnamespace ranges {
33204eeddc0SDimitry Andric
3330eae32dcSDimitry Andrictemplate <nothrow-forward-iterator ForwardIterator, nothrow-sentinel-for<ForwardIterator> Sentinel>
3340eae32dcSDimitry Andric  requires default_initializable<iter_value_t<ForwardIterator>>
33504eeddc0SDimitry Andric ForwardIterator uninitialized_value_construct(ForwardIterator first, Sentinel last); // since C++20
3360eae32dcSDimitry Andric
3370eae32dcSDimitry Andrictemplate <nothrow-forward-range ForwardRange>
3380eae32dcSDimitry Andric  requires default_initializable<range_value_t<ForwardRange>>
33904eeddc0SDimitry Andric borrowed_iterator_t<ForwardRange> uninitialized_value_construct(ForwardRange&& r); // since C++20
34004eeddc0SDimitry Andric
34104eeddc0SDimitry Andric}
3420eae32dcSDimitry Andric
3430b57cec5SDimitry Andrictemplate <class ForwardIterator, class Size>
3440b57cec5SDimitry Andric ForwardIterator uninitialized_value_construct_n(ForwardIterator first, Size n);
3450b57cec5SDimitry Andric
34604eeddc0SDimitry Andricnamespace ranges {
34704eeddc0SDimitry Andric
3480eae32dcSDimitry Andrictemplate <nothrow-forward-iterator ForwardIterator>
3490eae32dcSDimitry Andric  requires default_initializable<iter_value_t<ForwardIterator>>
35004eeddc0SDimitry Andric ForwardIterator uninitialized_value_construct_n(ForwardIterator first, iter_difference_t<ForwardIterator> n); // since C++20
35104eeddc0SDimitry Andric
35204eeddc0SDimitry Andric}
3530eae32dcSDimitry Andric
3540b57cec5SDimitry Andrictemplate <class ForwardIterator>
3550b57cec5SDimitry Andric void uninitialized_default_construct(ForwardIterator first, ForwardIterator last);
3560b57cec5SDimitry Andric
35704eeddc0SDimitry Andricnamespace ranges {
35804eeddc0SDimitry Andric
3590eae32dcSDimitry Andrictemplate <nothrow-forward-iterator ForwardIterator, nothrow-sentinel-for<ForwardIterator> Sentinel>
3600eae32dcSDimitry Andric  requires default_initializable<iter_value_t<ForwardIterator>>
36104eeddc0SDimitry Andric ForwardIterator uninitialized_default_construct(ForwardIterator first, Sentinel last); // since C++20
3620eae32dcSDimitry Andric
3630eae32dcSDimitry Andrictemplate <nothrow-forward-range ForwardRange>
3640eae32dcSDimitry Andric  requires default_initializable<range_value_t<ForwardRange>>
36504eeddc0SDimitry Andric borrowed_iterator_t<ForwardRange> uninitialized_default_construct(ForwardRange&& r); // since C++20
36604eeddc0SDimitry Andric
36704eeddc0SDimitry Andric}
3680eae32dcSDimitry Andric
3690b57cec5SDimitry Andrictemplate <class ForwardIterator, class Size>
3700b57cec5SDimitry Andric ForwardIterator uninitialized_default_construct_n(ForwardIterator first, Size n);
3710b57cec5SDimitry Andric
37204eeddc0SDimitry Andricnamespace ranges {
37304eeddc0SDimitry Andric
3740eae32dcSDimitry Andrictemplate <nothrow-forward-iterator ForwardIterator>
3750eae32dcSDimitry Andric  requires default_initializable<iter_value_t<ForwardIterator>>
37604eeddc0SDimitry Andric ForwardIterator uninitialized_default_construct_n(ForwardIterator first, iter_difference_t<ForwardIterator> n); // since C++20
37704eeddc0SDimitry Andric
37804eeddc0SDimitry Andric}
3790eae32dcSDimitry Andric
3800b57cec5SDimitry Andrictemplate <class Y> struct auto_ptr_ref {};      // deprecated in C++11, removed in C++17
3810b57cec5SDimitry Andric
3820b57cec5SDimitry Andrictemplate<class X>
3830b57cec5SDimitry Andricclass auto_ptr                                  // deprecated in C++11, removed in C++17
3840b57cec5SDimitry Andric{
3850b57cec5SDimitry Andricpublic:
3860b57cec5SDimitry Andric    typedef X element_type;
3870b57cec5SDimitry Andric
3880b57cec5SDimitry Andric    explicit auto_ptr(X* p =0) throw();
3890b57cec5SDimitry Andric    auto_ptr(auto_ptr&) throw();
3900b57cec5SDimitry Andric    template<class Y> auto_ptr(auto_ptr<Y>&) throw();
3910b57cec5SDimitry Andric    auto_ptr& operator=(auto_ptr&) throw();
3920b57cec5SDimitry Andric    template<class Y> auto_ptr& operator=(auto_ptr<Y>&) throw();
3930b57cec5SDimitry Andric    auto_ptr& operator=(auto_ptr_ref<X> r) throw();
3940b57cec5SDimitry Andric    ~auto_ptr() throw();
3950b57cec5SDimitry Andric
3960b57cec5SDimitry Andric    typename add_lvalue_reference<X>::type operator*() const throw();
3970b57cec5SDimitry Andric    X* operator->() const throw();
3980b57cec5SDimitry Andric    X* get() const throw();
3990b57cec5SDimitry Andric    X* release() throw();
4000b57cec5SDimitry Andric    void reset(X* p =0) throw();
4010b57cec5SDimitry Andric
4020b57cec5SDimitry Andric    auto_ptr(auto_ptr_ref<X>) throw();
4030b57cec5SDimitry Andric    template<class Y> operator auto_ptr_ref<Y>() throw();
4040b57cec5SDimitry Andric    template<class Y> operator auto_ptr<Y>() throw();
4050b57cec5SDimitry Andric};
4060b57cec5SDimitry Andric
4070b57cec5SDimitry Andrictemplate <class T>
4080b57cec5SDimitry Andricstruct default_delete
4090b57cec5SDimitry Andric{
4100b57cec5SDimitry Andric    constexpr default_delete() noexcept = default;
411bdd1243dSDimitry Andric    template <class U> constexpr default_delete(const default_delete<U>&) noexcept; // constexpr since C++23
4120b57cec5SDimitry Andric
413bdd1243dSDimitry Andric    constexpr void operator()(T*) const noexcept;                                   // constexpr since C++23
4140b57cec5SDimitry Andric};
4150b57cec5SDimitry Andric
4160b57cec5SDimitry Andrictemplate <class T>
4170b57cec5SDimitry Andricstruct default_delete<T[]>
4180b57cec5SDimitry Andric{
4190b57cec5SDimitry Andric    constexpr default_delete() noexcept = default;
420bdd1243dSDimitry Andric    template <class U> constexpr default_delete(const default_delete <U[]>&) noexcept; // constexpr since C++23
421bdd1243dSDimitry Andric    constexpr void operator()(T*) const noexcept;                                      // constexpr since C++23
4220b57cec5SDimitry Andric    template <class U> void operator()(U*) const = delete;
4230b57cec5SDimitry Andric};
4240b57cec5SDimitry Andric
4250b57cec5SDimitry Andrictemplate <class T, class D = default_delete<T>>
4260b57cec5SDimitry Andricclass unique_ptr
4270b57cec5SDimitry Andric{
4280b57cec5SDimitry Andricpublic:
4290b57cec5SDimitry Andric    typedef see below pointer;
4300b57cec5SDimitry Andric    typedef T element_type;
4310b57cec5SDimitry Andric    typedef D deleter_type;
4320b57cec5SDimitry Andric
4330b57cec5SDimitry Andric    // constructors
4340b57cec5SDimitry Andric    constexpr unique_ptr() noexcept;
435bdd1243dSDimitry Andric    constexpr explicit unique_ptr(pointer p) noexcept;           // constexpr since C++23
436bdd1243dSDimitry Andric    constexpr unique_ptr(pointer p, see below d1) noexcept;      // constexpr since C++23
437bdd1243dSDimitry Andric    constexpr unique_ptr(pointer p, see below d2) noexcept;      // constexpr since C++23
438bdd1243dSDimitry Andric    constexpr unique_ptr(unique_ptr&& u) noexcept;               // constexpr since C++23
439bdd1243dSDimitry Andric    constexpr unique_ptr(nullptr_t) noexcept : unique_ptr() { }
4400b57cec5SDimitry Andric    template <class U, class E>
441bdd1243dSDimitry Andric        constexpr unique_ptr(unique_ptr<U, E>&& u) noexcept;     // constexpr since C++23
4420b57cec5SDimitry Andric    template <class U>
4430b57cec5SDimitry Andric        unique_ptr(auto_ptr<U>&& u) noexcept;                    // removed in C++17
4440b57cec5SDimitry Andric
4450b57cec5SDimitry Andric    // destructor
446bdd1243dSDimitry Andric    constexpr ~unique_ptr();                                     // constexpr since C++23
4470b57cec5SDimitry Andric
4480b57cec5SDimitry Andric    // assignment
449bdd1243dSDimitry Andric    constexpr unique_ptr& operator=(unique_ptr&& u) noexcept;                         // constexpr since C++23
450bdd1243dSDimitry Andric    template <class U, class E>
451bdd1243dSDimitry Andric    constexpr unique_ptr& operator=(unique_ptr<U, E>&& u) noexcept;                   // constexpr since C++23
452bdd1243dSDimitry Andric    constexpr unique_ptr& operator=(nullptr_t) noexcept;                              // constexpr since C++23
4530b57cec5SDimitry Andric
4540b57cec5SDimitry Andric    // observers
455bdd1243dSDimitry Andric    typename constexpr add_lvalue_reference<T>::type operator*() const;               // constexpr since C++23
456bdd1243dSDimitry Andric    constexpr pointer operator->() const noexcept;                                    // constexpr since C++23
457bdd1243dSDimitry Andric    constexpr pointer get() const noexcept;                                           // constexpr since C++23
458bdd1243dSDimitry Andric    constexpr deleter_type& get_deleter() noexcept;                                   // constexpr since C++23
459bdd1243dSDimitry Andric    constexpr const deleter_type& get_deleter() const noexcept;                       // constexpr since C++23
460bdd1243dSDimitry Andric    constexpr explicit operator bool() const noexcept;                                // constexpr since C++23
4610b57cec5SDimitry Andric
4620b57cec5SDimitry Andric    // modifiers
463bdd1243dSDimitry Andric    constexpr pointer release() noexcept;                                             // constexpr since C++23
464bdd1243dSDimitry Andric    constexpr void reset(pointer p = pointer()) noexcept;                             // constexpr since C++23
465bdd1243dSDimitry Andric    constexpr void swap(unique_ptr& u) noexcept;                                      // constexpr since C++23
4660b57cec5SDimitry Andric};
4670b57cec5SDimitry Andric
4680b57cec5SDimitry Andrictemplate <class T, class D>
4690b57cec5SDimitry Andricclass unique_ptr<T[], D>
4700b57cec5SDimitry Andric{
4710b57cec5SDimitry Andricpublic:
4720b57cec5SDimitry Andric    typedef implementation-defined pointer;
4730b57cec5SDimitry Andric    typedef T element_type;
4740b57cec5SDimitry Andric    typedef D deleter_type;
4750b57cec5SDimitry Andric
4760b57cec5SDimitry Andric    // constructors
4770b57cec5SDimitry Andric    constexpr unique_ptr() noexcept;
478bdd1243dSDimitry Andric    constexpr explicit unique_ptr(pointer p) noexcept;          // constexpr since C++23
479bdd1243dSDimitry Andric    constexpr unique_ptr(pointer p, see below d) noexcept;      // constexpr since C++23
480bdd1243dSDimitry Andric    constexpr unique_ptr(pointer p, see below d) noexcept;      // constexpr since C++23
481bdd1243dSDimitry Andric    constexpr unique_ptr(unique_ptr&& u) noexcept;              // constexpr since C++23
482bdd1243dSDimitry Andric    template <class U, class E>
483bdd1243dSDimitry Andric    constexpr unique_ptr(unique_ptr <U, E>&& u) noexcept;       // constexpr since C++23
484bdd1243dSDimitry Andric    constexpr unique_ptr(nullptr_t) noexcept : unique_ptr() { }
4850b57cec5SDimitry Andric
4860b57cec5SDimitry Andric    // destructor
487bdd1243dSDimitry Andric    constexpr ~unique_ptr();                                    // constexpr since C++23
4880b57cec5SDimitry Andric
4890b57cec5SDimitry Andric    // assignment
490bdd1243dSDimitry Andric    constexpr unique_ptr& operator=(unique_ptr&& u) noexcept;        // constexpr since C++23
491bdd1243dSDimitry Andric    template <class U, class E>
492bdd1243dSDimitry Andric    constexpr unique_ptr& operator=(unique_ptr <U, E>&& u) noexcept; // constexpr since C++23
493bdd1243dSDimitry Andric    constexpr unique_ptr& operator=(nullptr_t) noexcept;             // constexpr since C++23
4940b57cec5SDimitry Andric
4950b57cec5SDimitry Andric    // observers
496bdd1243dSDimitry Andric    constexpr T& operator[](size_t i) const;                    // constexpr since C++23
497bdd1243dSDimitry Andric    constexpr pointer get() const noexcept;                     // constexpr since C++23
498bdd1243dSDimitry Andric    constexpr deleter_type& get_deleter() noexcept;             // constexpr since C++23
499bdd1243dSDimitry Andric    constexpr const deleter_type& get_deleter() const noexcept; // constexpr since C++23
500bdd1243dSDimitry Andric    constexpr explicit operator bool() const noexcept;          // constexpr since C++23
5010b57cec5SDimitry Andric
5020b57cec5SDimitry Andric    // modifiers
503bdd1243dSDimitry Andric    constexpr pointer release() noexcept;                       // constexpr since C++23
504bdd1243dSDimitry Andric    constexpr void reset(pointer p = pointer()) noexcept;       // constexpr since C++23
505bdd1243dSDimitry Andric    constexpr void reset(nullptr_t) noexcept;                   // constexpr since C++23
5060b57cec5SDimitry Andric  template <class U> void reset(U) = delete;
507bdd1243dSDimitry Andric    constexpr void swap(unique_ptr& u) noexcept;                // constexpr since C++23
5080b57cec5SDimitry Andric};
5090b57cec5SDimitry Andric
5100b57cec5SDimitry Andrictemplate <class T, class D>
511bdd1243dSDimitry Andric    constexpr void swap(unique_ptr<T, D>& x, unique_ptr<T, D>& y) noexcept;                 // constexpr since C++23
5120b57cec5SDimitry Andric
5130b57cec5SDimitry Andrictemplate <class T1, class D1, class T2, class D2>
514bdd1243dSDimitry Andric    constexpr bool operator==(const unique_ptr<T1, D1>& x, const unique_ptr<T2, D2>& y);    // constexpr since C++23
5150b57cec5SDimitry Andrictemplate <class T1, class D1, class T2, class D2>
516bdd1243dSDimitry Andric    bool operator!=(const unique_ptr<T1, D1>& x, const unique_ptr<T2, D2>& y);              // removed in C++20
5170b57cec5SDimitry Andrictemplate <class T1, class D1, class T2, class D2>
5180b57cec5SDimitry Andric    bool operator<(const unique_ptr<T1, D1>& x, const unique_ptr<T2, D2>& y);
5190b57cec5SDimitry Andrictemplate <class T1, class D1, class T2, class D2>
5200b57cec5SDimitry Andric    bool operator<=(const unique_ptr<T1, D1>& x, const unique_ptr<T2, D2>& y);
5210b57cec5SDimitry Andrictemplate <class T1, class D1, class T2, class D2>
5220b57cec5SDimitry Andric    bool operator>(const unique_ptr<T1, D1>& x, const unique_ptr<T2, D2>& y);
5230b57cec5SDimitry Andrictemplate <class T1, class D1, class T2, class D2>
5240b57cec5SDimitry Andric    bool operator>=(const unique_ptr<T1, D1>& x, const unique_ptr<T2, D2>& y);
525bdd1243dSDimitry Andrictemplate<class T1, class D1, class T2, class D2>
526bdd1243dSDimitry Andric  requires three_way_comparable_with<typename unique_ptr<T1, D1>::pointer,
527bdd1243dSDimitry Andric                                     typename unique_ptr<T2, D2>::pointer>
528bdd1243dSDimitry Andric  compare_three_way_result_t<typename unique_ptr<T1, D1>::pointer,
529bdd1243dSDimitry Andric                             typename unique_ptr<T2, D2>::pointer>
530bdd1243dSDimitry Andric    operator<=>(const unique_ptr<T1, D1>& x, const unique_ptr<T2, D2>& y);      // C++20
5310b57cec5SDimitry Andric
5320b57cec5SDimitry Andrictemplate <class T, class D>
533bdd1243dSDimitry Andric    constexpr bool operator==(const unique_ptr<T, D>& x, nullptr_t) noexcept;   // constexpr since C++23
5340b57cec5SDimitry Andrictemplate <class T, class D>
535bdd1243dSDimitry Andric    bool operator==(nullptr_t, const unique_ptr<T, D>& y) noexcept;             // removed in C++20
5360b57cec5SDimitry Andrictemplate <class T, class D>
537bdd1243dSDimitry Andric    bool operator!=(const unique_ptr<T, D>& x, nullptr_t) noexcept;             // removed in C++20
5380b57cec5SDimitry Andrictemplate <class T, class D>
539bdd1243dSDimitry Andric    bool operator!=(nullptr_t, const unique_ptr<T, D>& y) noexcept;             // removed in C++20
5400b57cec5SDimitry Andric
5410b57cec5SDimitry Andrictemplate <class T, class D>
542bdd1243dSDimitry Andric    constexpr bool operator<(const unique_ptr<T, D>& x, nullptr_t);     // constexpr since C++23
5430b57cec5SDimitry Andrictemplate <class T, class D>
544bdd1243dSDimitry Andric    constexpr bool operator<(nullptr_t, const unique_ptr<T, D>& y);     // constexpr since C++23
5450b57cec5SDimitry Andrictemplate <class T, class D>
546bdd1243dSDimitry Andric    constexpr bool operator<=(const unique_ptr<T, D>& x, nullptr_t);    // constexpr since C++23
5470b57cec5SDimitry Andrictemplate <class T, class D>
548bdd1243dSDimitry Andric    constexpr bool operator<=(nullptr_t, const unique_ptr<T, D>& y);    // constexpr since C++23
5490b57cec5SDimitry Andrictemplate <class T, class D>
550bdd1243dSDimitry Andric    constexpr bool operator>(const unique_ptr<T, D>& x, nullptr_t);     // constexpr since C++23
5510b57cec5SDimitry Andrictemplate <class T, class D>
552bdd1243dSDimitry Andric    constexpr bool operator>(nullptr_t, const unique_ptr<T, D>& y);     // constexpr since C++23
5530b57cec5SDimitry Andrictemplate <class T, class D>
554bdd1243dSDimitry Andric    constexpr bool operator>=(const unique_ptr<T, D>& x, nullptr_t);    // constexpr since C++23
5550b57cec5SDimitry Andrictemplate <class T, class D>
556bdd1243dSDimitry Andric    constexpr bool operator>=(nullptr_t, const unique_ptr<T, D>& y);    // constexpr since C++23
557bdd1243dSDimitry Andrictemplate<class T, class D>
558bdd1243dSDimitry Andric  requires three_way_comparable<typename unique_ptr<T, D>::pointer>
559bdd1243dSDimitry Andric  compare_three_way_result_t<typename unique_ptr<T, D>::pointer>
560bdd1243dSDimitry Andric    constexpr operator<=>(const unique_ptr<T, D>& x, nullptr_t);        // C++20, constexpr since C++23
5610b57cec5SDimitry Andric
5620b57cec5SDimitry Andricclass bad_weak_ptr
5630b57cec5SDimitry Andric    : public std::exception
5640b57cec5SDimitry Andric{
5650b57cec5SDimitry Andric    bad_weak_ptr() noexcept;
5660b57cec5SDimitry Andric};
5670b57cec5SDimitry Andric
568bdd1243dSDimitry Andrictemplate<class T, class... Args>
569bdd1243dSDimitry Andricconstexpr unique_ptr<T> make_unique(Args&&... args);                            // C++14, constexpr since C++23
570bdd1243dSDimitry Andrictemplate<class T>
571bdd1243dSDimitry Andricconstexpr unique_ptr<T> make_unique(size_t n);                                  // C++14, constexpr since C++23
5720b57cec5SDimitry Andrictemplate<class T, class... Args> unspecified   make_unique(Args&&...) = delete; // C++14, T == U[N]
5730b57cec5SDimitry Andric
574bdd1243dSDimitry Andrictemplate<class T>
575bdd1243dSDimitry Andric  constexpr unique_ptr<T> make_unique_for_overwrite();                        // T is not array, C++20, constexpr since C++23
576bdd1243dSDimitry Andrictemplate<class T>
577bdd1243dSDimitry Andric  constexpr unique_ptr<T> make_unique_for_overwrite(size_t n);                // T is U[], C++20, constexpr since C++23
578bdd1243dSDimitry Andrictemplate<class T, class... Args>
579bdd1243dSDimitry Andric  unspecified make_unique_for_overwrite(Args&&...) = delete;                  // T is U[N], C++20
580bdd1243dSDimitry Andric
5810b57cec5SDimitry Andrictemplate<class E, class T, class Y, class D>
5820b57cec5SDimitry Andric    basic_ostream<E, T>& operator<< (basic_ostream<E, T>& os, unique_ptr<Y, D> const& p);
5830b57cec5SDimitry Andric
5840b57cec5SDimitry Andrictemplate<class T>
5850b57cec5SDimitry Andricclass shared_ptr
5860b57cec5SDimitry Andric{
5870b57cec5SDimitry Andricpublic:
588349cc55cSDimitry Andric    typedef T element_type; // until C++17
589349cc55cSDimitry Andric    typedef remove_extent_t<T> element_type; // since C++17
5900b57cec5SDimitry Andric    typedef weak_ptr<T> weak_type; // C++17
5910b57cec5SDimitry Andric
5920b57cec5SDimitry Andric    // constructors:
5930b57cec5SDimitry Andric    constexpr shared_ptr() noexcept;
5940b57cec5SDimitry Andric    template<class Y> explicit shared_ptr(Y* p);
5950b57cec5SDimitry Andric    template<class Y, class D> shared_ptr(Y* p, D d);
5960b57cec5SDimitry Andric    template<class Y, class D, class A> shared_ptr(Y* p, D d, A a);
5970b57cec5SDimitry Andric    template <class D> shared_ptr(nullptr_t p, D d);
5980b57cec5SDimitry Andric    template <class D, class A> shared_ptr(nullptr_t p, D d, A a);
5990b57cec5SDimitry Andric    template<class Y> shared_ptr(const shared_ptr<Y>& r, T *p) noexcept;
6000b57cec5SDimitry Andric    shared_ptr(const shared_ptr& r) noexcept;
6010b57cec5SDimitry Andric    template<class Y> shared_ptr(const shared_ptr<Y>& r) noexcept;
6020b57cec5SDimitry Andric    shared_ptr(shared_ptr&& r) noexcept;
6030b57cec5SDimitry Andric    template<class Y> shared_ptr(shared_ptr<Y>&& r) noexcept;
6040b57cec5SDimitry Andric    template<class Y> explicit shared_ptr(const weak_ptr<Y>& r);
6050b57cec5SDimitry Andric    template<class Y> shared_ptr(auto_ptr<Y>&& r);          // removed in C++17
6060b57cec5SDimitry Andric    template <class Y, class D> shared_ptr(unique_ptr<Y, D>&& r);
6070b57cec5SDimitry Andric    shared_ptr(nullptr_t) : shared_ptr() { }
6080b57cec5SDimitry Andric
6090b57cec5SDimitry Andric    // destructor:
6100b57cec5SDimitry Andric    ~shared_ptr();
6110b57cec5SDimitry Andric
6120b57cec5SDimitry Andric    // assignment:
6130b57cec5SDimitry Andric    shared_ptr& operator=(const shared_ptr& r) noexcept;
6140b57cec5SDimitry Andric    template<class Y> shared_ptr& operator=(const shared_ptr<Y>& r) noexcept;
6150b57cec5SDimitry Andric    shared_ptr& operator=(shared_ptr&& r) noexcept;
6160b57cec5SDimitry Andric    template<class Y> shared_ptr& operator=(shared_ptr<Y>&& r);
6170b57cec5SDimitry Andric    template<class Y> shared_ptr& operator=(auto_ptr<Y>&& r); // removed in C++17
6180b57cec5SDimitry Andric    template <class Y, class D> shared_ptr& operator=(unique_ptr<Y, D>&& r);
6190b57cec5SDimitry Andric
6200b57cec5SDimitry Andric    // modifiers:
6210b57cec5SDimitry Andric    void swap(shared_ptr& r) noexcept;
6220b57cec5SDimitry Andric    void reset() noexcept;
6230b57cec5SDimitry Andric    template<class Y> void reset(Y* p);
6240b57cec5SDimitry Andric    template<class Y, class D> void reset(Y* p, D d);
6250b57cec5SDimitry Andric    template<class Y, class D, class A> void reset(Y* p, D d, A a);
6260b57cec5SDimitry Andric
6270b57cec5SDimitry Andric    // observers:
6280b57cec5SDimitry Andric    T* get() const noexcept;
6290b57cec5SDimitry Andric    T& operator*() const noexcept;
6300b57cec5SDimitry Andric    T* operator->() const noexcept;
6310b57cec5SDimitry Andric    long use_count() const noexcept;
632647cbc5dSDimitry Andric    bool unique() const noexcept;  // deprected in C++17, removed in C++20
6330b57cec5SDimitry Andric    explicit operator bool() const noexcept;
6340b57cec5SDimitry Andric    template<class U> bool owner_before(shared_ptr<U> const& b) const noexcept;
6350b57cec5SDimitry Andric    template<class U> bool owner_before(weak_ptr<U> const& b) const noexcept;
6360b57cec5SDimitry Andric};
6370b57cec5SDimitry Andric
6385ffd83dbSDimitry Andrictemplate<class T>
6395ffd83dbSDimitry Andricshared_ptr(weak_ptr<T>) -> shared_ptr<T>;
6405ffd83dbSDimitry Andrictemplate<class T, class D>
6415ffd83dbSDimitry Andricshared_ptr(unique_ptr<T, D>) -> shared_ptr<T>;
6425ffd83dbSDimitry Andric
6430b57cec5SDimitry Andric// shared_ptr comparisons:
6440b57cec5SDimitry Andrictemplate<class T, class U>
6450b57cec5SDimitry Andric    bool operator==(shared_ptr<T> const& a, shared_ptr<U> const& b) noexcept;
6460b57cec5SDimitry Andrictemplate<class T, class U>
647bdd1243dSDimitry Andric    bool operator!=(shared_ptr<T> const& a, shared_ptr<U> const& b) noexcept;               // removed in C++20
6480b57cec5SDimitry Andrictemplate<class T, class U>
649bdd1243dSDimitry Andric    bool operator<(shared_ptr<T> const& a, shared_ptr<U> const& b) noexcept;                // removed in C++20
6500b57cec5SDimitry Andrictemplate<class T, class U>
651bdd1243dSDimitry Andric    bool operator>(shared_ptr<T> const& a, shared_ptr<U> const& b) noexcept;                // removed in C++20
6520b57cec5SDimitry Andrictemplate<class T, class U>
653bdd1243dSDimitry Andric    bool operator<=(shared_ptr<T> const& a, shared_ptr<U> const& b) noexcept;               // removed in C++20
6540b57cec5SDimitry Andrictemplate<class T, class U>
655bdd1243dSDimitry Andric    bool operator>=(shared_ptr<T> const& a, shared_ptr<U> const& b) noexcept;               // removed in C++20
656bdd1243dSDimitry Andrictemplate<class T, class U>
657bdd1243dSDimitry Andric    strong_ordering operator<=>(shared_ptr<T> const& a, shared_ptr<U> const& b) noexcept;   // C++20
6580b57cec5SDimitry Andric
6590b57cec5SDimitry Andrictemplate <class T>
6600b57cec5SDimitry Andric    bool operator==(const shared_ptr<T>& x, nullptr_t) noexcept;
6610b57cec5SDimitry Andrictemplate <class T>
662bdd1243dSDimitry Andric    bool operator==(nullptr_t, const shared_ptr<T>& y) noexcept;               // removed in C++20
6630b57cec5SDimitry Andrictemplate <class T>
664bdd1243dSDimitry Andric    bool operator!=(const shared_ptr<T>& x, nullptr_t) noexcept;               // removed in C++20
6650b57cec5SDimitry Andrictemplate <class T>
666bdd1243dSDimitry Andric    bool operator!=(nullptr_t, const shared_ptr<T>& y) noexcept;               // removed in C++20
6670b57cec5SDimitry Andrictemplate <class T>
668bdd1243dSDimitry Andric    bool operator<(const shared_ptr<T>& x, nullptr_t) noexcept;                // removed in C++20
6690b57cec5SDimitry Andrictemplate <class T>
670bdd1243dSDimitry Andric    bool operator<(nullptr_t, const shared_ptr<T>& y) noexcept;                // removed in C++20
6710b57cec5SDimitry Andrictemplate <class T>
672bdd1243dSDimitry Andric    bool operator<=(const shared_ptr<T>& x, nullptr_t) noexcept;               // removed in C++20
6730b57cec5SDimitry Andrictemplate <class T>
674bdd1243dSDimitry Andric    bool operator<=(nullptr_t, const shared_ptr<T>& y) noexcept;               // removed in C++20
6750b57cec5SDimitry Andrictemplate <class T>
676bdd1243dSDimitry Andric    bool operator>(const shared_ptr<T>& x, nullptr_t) noexcept;                // removed in C++20
6770b57cec5SDimitry Andrictemplate <class T>
678bdd1243dSDimitry Andric    bool operator>(nullptr_t, const shared_ptr<T>& y) noexcept;                // removed in C++20
6790b57cec5SDimitry Andrictemplate <class T>
680bdd1243dSDimitry Andric    bool operator>=(const shared_ptr<T>& x, nullptr_t) noexcept;               // removed in C++20
6810b57cec5SDimitry Andrictemplate <class T>
682bdd1243dSDimitry Andric    bool operator>=(nullptr_t, const shared_ptr<T>& y) noexcept;               // removed in C++20
683bdd1243dSDimitry Andrictemplate<class T>
684bdd1243dSDimitry Andric    strong_ordering operator<=>(shared_ptr<T> const& x, nullptr_t) noexcept;   // C++20
6850b57cec5SDimitry Andric
6860b57cec5SDimitry Andric// shared_ptr specialized algorithms:
6870b57cec5SDimitry Andrictemplate<class T> void swap(shared_ptr<T>& a, shared_ptr<T>& b) noexcept;
6880b57cec5SDimitry Andric
6890b57cec5SDimitry Andric// shared_ptr casts:
6900b57cec5SDimitry Andrictemplate<class T, class U>
6910b57cec5SDimitry Andric    shared_ptr<T> static_pointer_cast(shared_ptr<U> const& r) noexcept;
6920b57cec5SDimitry Andrictemplate<class T, class U>
6930b57cec5SDimitry Andric    shared_ptr<T> dynamic_pointer_cast(shared_ptr<U> const& r) noexcept;
6940b57cec5SDimitry Andrictemplate<class T, class U>
6950b57cec5SDimitry Andric    shared_ptr<T> const_pointer_cast(shared_ptr<U> const& r) noexcept;
6960b57cec5SDimitry Andric
6970b57cec5SDimitry Andric// shared_ptr I/O:
6980b57cec5SDimitry Andrictemplate<class E, class T, class Y>
6990b57cec5SDimitry Andric    basic_ostream<E, T>& operator<< (basic_ostream<E, T>& os, shared_ptr<Y> const& p);
7000b57cec5SDimitry Andric
7010b57cec5SDimitry Andric// shared_ptr get_deleter:
7020b57cec5SDimitry Andrictemplate<class D, class T> D* get_deleter(shared_ptr<T> const& p) noexcept;
7030b57cec5SDimitry Andric
7040b57cec5SDimitry Andrictemplate<class T, class... Args>
70581ad6265SDimitry Andric    shared_ptr<T> make_shared(Args&&... args); // T is not an array
7060b57cec5SDimitry Andrictemplate<class T, class A, class... Args>
70781ad6265SDimitry Andric    shared_ptr<T> allocate_shared(const A& a, Args&&... args); // T is not an array
70881ad6265SDimitry Andric
70981ad6265SDimitry Andrictemplate<class T>
71081ad6265SDimitry Andric    shared_ptr<T> make_shared(size_t N); // T is U[] (since C++20)
71181ad6265SDimitry Andrictemplate<class T, class A>
71281ad6265SDimitry Andric    shared_ptr<T> allocate_shared(const A& a, size_t N); // T is U[] (since C++20)
71381ad6265SDimitry Andric
71481ad6265SDimitry Andrictemplate<class T>
71581ad6265SDimitry Andric    shared_ptr<T> make_shared(); // T is U[N] (since C++20)
71681ad6265SDimitry Andrictemplate<class T, class A>
71781ad6265SDimitry Andric    shared_ptr<T> allocate_shared(const A& a); // T is U[N] (since C++20)
71881ad6265SDimitry Andric
71981ad6265SDimitry Andrictemplate<class T>
72081ad6265SDimitry Andric    shared_ptr<T> make_shared(size_t N, const remove_extent_t<T>& u); // T is U[] (since C++20)
72181ad6265SDimitry Andrictemplate<class T, class A>
72281ad6265SDimitry Andric    shared_ptr<T> allocate_shared(const A& a, size_t N, const remove_extent_t<T>& u); // T is U[] (since C++20)
72381ad6265SDimitry Andric
72481ad6265SDimitry Andrictemplate<class T> shared_ptr<T>
72581ad6265SDimitry Andric    make_shared(const remove_extent_t<T>& u); // T is U[N] (since C++20)
72681ad6265SDimitry Andrictemplate<class T, class A>
72781ad6265SDimitry Andric    shared_ptr<T> allocate_shared(const A& a, const remove_extent_t<T>& u); // T is U[N] (since C++20)
7280b57cec5SDimitry Andric
7290b57cec5SDimitry Andrictemplate<class T>
730bdd1243dSDimitry Andric  shared_ptr<T> make_shared_for_overwrite();                                  // T is not U[], C++20
731bdd1243dSDimitry Andrictemplate<class T, class A>
732bdd1243dSDimitry Andric  shared_ptr<T> allocate_shared_for_overwrite(const A& a);                    // T is not U[], C++20
733bdd1243dSDimitry Andric
734bdd1243dSDimitry Andrictemplate<class T>
735bdd1243dSDimitry Andric  shared_ptr<T> make_shared_for_overwrite(size_t N);                          // T is U[], C++20
736bdd1243dSDimitry Andrictemplate<class T, class A>
737bdd1243dSDimitry Andric  shared_ptr<T> allocate_shared_for_overwrite(const A& a, size_t N);          // T is U[], C++20
738bdd1243dSDimitry Andric
739bdd1243dSDimitry Andrictemplate<class T>
7400b57cec5SDimitry Andricclass weak_ptr
7410b57cec5SDimitry Andric{
7420b57cec5SDimitry Andricpublic:
743349cc55cSDimitry Andric    typedef T element_type; // until C++17
744349cc55cSDimitry Andric    typedef remove_extent_t<T> element_type; // since C++17
7450b57cec5SDimitry Andric
7460b57cec5SDimitry Andric    // constructors
7470b57cec5SDimitry Andric    constexpr weak_ptr() noexcept;
7480b57cec5SDimitry Andric    template<class Y> weak_ptr(shared_ptr<Y> const& r) noexcept;
7490b57cec5SDimitry Andric    weak_ptr(weak_ptr const& r) noexcept;
7500b57cec5SDimitry Andric    template<class Y> weak_ptr(weak_ptr<Y> const& r) noexcept;
7510b57cec5SDimitry Andric    weak_ptr(weak_ptr&& r) noexcept;                      // C++14
7520b57cec5SDimitry Andric    template<class Y> weak_ptr(weak_ptr<Y>&& r) noexcept; // C++14
7530b57cec5SDimitry Andric
7540b57cec5SDimitry Andric    // destructor
7550b57cec5SDimitry Andric    ~weak_ptr();
7560b57cec5SDimitry Andric
7570b57cec5SDimitry Andric    // assignment
7580b57cec5SDimitry Andric    weak_ptr& operator=(weak_ptr const& r) noexcept;
7590b57cec5SDimitry Andric    template<class Y> weak_ptr& operator=(weak_ptr<Y> const& r) noexcept;
7600b57cec5SDimitry Andric    template<class Y> weak_ptr& operator=(shared_ptr<Y> const& r) noexcept;
7610b57cec5SDimitry Andric    weak_ptr& operator=(weak_ptr&& r) noexcept;                      // C++14
7620b57cec5SDimitry Andric    template<class Y> weak_ptr& operator=(weak_ptr<Y>&& r) noexcept; // C++14
7630b57cec5SDimitry Andric
7640b57cec5SDimitry Andric    // modifiers
7650b57cec5SDimitry Andric    void swap(weak_ptr& r) noexcept;
7660b57cec5SDimitry Andric    void reset() noexcept;
7670b57cec5SDimitry Andric
7680b57cec5SDimitry Andric    // observers
7690b57cec5SDimitry Andric    long use_count() const noexcept;
7700b57cec5SDimitry Andric    bool expired() const noexcept;
7710b57cec5SDimitry Andric    shared_ptr<T> lock() const noexcept;
7720b57cec5SDimitry Andric    template<class U> bool owner_before(shared_ptr<U> const& b) const noexcept;
7730b57cec5SDimitry Andric    template<class U> bool owner_before(weak_ptr<U> const& b) const noexcept;
7740b57cec5SDimitry Andric};
7750b57cec5SDimitry Andric
7765ffd83dbSDimitry Andrictemplate<class T>
7775ffd83dbSDimitry Andricweak_ptr(shared_ptr<T>) -> weak_ptr<T>;
7785ffd83dbSDimitry Andric
7790b57cec5SDimitry Andric// weak_ptr specialized algorithms:
7800b57cec5SDimitry Andrictemplate<class T> void swap(weak_ptr<T>& a, weak_ptr<T>& b) noexcept;
7810b57cec5SDimitry Andric
7820b57cec5SDimitry Andric// class owner_less:
7830b57cec5SDimitry Andrictemplate<class T> struct owner_less;
7840b57cec5SDimitry Andric
7850b57cec5SDimitry Andrictemplate<class T>
7860b57cec5SDimitry Andricstruct owner_less<shared_ptr<T> >
7870b57cec5SDimitry Andric    : binary_function<shared_ptr<T>, shared_ptr<T>, bool>
7880b57cec5SDimitry Andric{
7890b57cec5SDimitry Andric    typedef bool result_type;
7900b57cec5SDimitry Andric    bool operator()(shared_ptr<T> const&, shared_ptr<T> const&) const noexcept;
7910b57cec5SDimitry Andric    bool operator()(shared_ptr<T> const&, weak_ptr<T> const&) const noexcept;
7920b57cec5SDimitry Andric    bool operator()(weak_ptr<T> const&, shared_ptr<T> const&) const noexcept;
7930b57cec5SDimitry Andric};
7940b57cec5SDimitry Andric
7950b57cec5SDimitry Andrictemplate<class T>
7960b57cec5SDimitry Andricstruct owner_less<weak_ptr<T> >
7970b57cec5SDimitry Andric    : binary_function<weak_ptr<T>, weak_ptr<T>, bool>
7980b57cec5SDimitry Andric{
7990b57cec5SDimitry Andric    typedef bool result_type;
8000b57cec5SDimitry Andric    bool operator()(weak_ptr<T> const&, weak_ptr<T> const&) const noexcept;
8010b57cec5SDimitry Andric    bool operator()(shared_ptr<T> const&, weak_ptr<T> const&) const noexcept;
8020b57cec5SDimitry Andric    bool operator()(weak_ptr<T> const&, shared_ptr<T> const&) const noexcept;
8030b57cec5SDimitry Andric};
8040b57cec5SDimitry Andric
8050b57cec5SDimitry Andrictemplate <>  // Added in C++14
8060b57cec5SDimitry Andricstruct owner_less<void>
8070b57cec5SDimitry Andric{
8080b57cec5SDimitry Andric    template <class _Tp, class _Up>
8090b57cec5SDimitry Andric    bool operator()( shared_ptr<_Tp> const& __x, shared_ptr<_Up> const& __y) const noexcept;
8100b57cec5SDimitry Andric    template <class _Tp, class _Up>
8110b57cec5SDimitry Andric    bool operator()( shared_ptr<_Tp> const& __x,   weak_ptr<_Up> const& __y) const noexcept;
8120b57cec5SDimitry Andric    template <class _Tp, class _Up>
8130b57cec5SDimitry Andric    bool operator()(   weak_ptr<_Tp> const& __x, shared_ptr<_Up> const& __y) const noexcept;
8140b57cec5SDimitry Andric    template <class _Tp, class _Up>
8150b57cec5SDimitry Andric    bool operator()(   weak_ptr<_Tp> const& __x,   weak_ptr<_Up> const& __y) const noexcept;
8160b57cec5SDimitry Andric
8170b57cec5SDimitry Andric    typedef void is_transparent;
8180b57cec5SDimitry Andric};
8190b57cec5SDimitry Andric
8200b57cec5SDimitry Andrictemplate<class T>
8210b57cec5SDimitry Andricclass enable_shared_from_this
8220b57cec5SDimitry Andric{
8230b57cec5SDimitry Andricprotected:
8240b57cec5SDimitry Andric    constexpr enable_shared_from_this() noexcept;
8250b57cec5SDimitry Andric    enable_shared_from_this(enable_shared_from_this const&) noexcept;
8260b57cec5SDimitry Andric    enable_shared_from_this& operator=(enable_shared_from_this const&) noexcept;
8270b57cec5SDimitry Andric    ~enable_shared_from_this();
8280b57cec5SDimitry Andricpublic:
8290b57cec5SDimitry Andric    shared_ptr<T> shared_from_this();
8300b57cec5SDimitry Andric    shared_ptr<T const> shared_from_this() const;
8310b57cec5SDimitry Andric};
8320b57cec5SDimitry Andric
8330b57cec5SDimitry Andrictemplate<class T>
8340b57cec5SDimitry Andric    bool atomic_is_lock_free(const shared_ptr<T>* p);
8350b57cec5SDimitry Andrictemplate<class T>
8360b57cec5SDimitry Andric    shared_ptr<T> atomic_load(const shared_ptr<T>* p);
8370b57cec5SDimitry Andrictemplate<class T>
8380b57cec5SDimitry Andric    shared_ptr<T> atomic_load_explicit(const shared_ptr<T>* p, memory_order mo);
8390b57cec5SDimitry Andrictemplate<class T>
8400b57cec5SDimitry Andric    void atomic_store(shared_ptr<T>* p, shared_ptr<T> r);
8410b57cec5SDimitry Andrictemplate<class T>
8420b57cec5SDimitry Andric    void atomic_store_explicit(shared_ptr<T>* p, shared_ptr<T> r, memory_order mo);
8430b57cec5SDimitry Andrictemplate<class T>
8440b57cec5SDimitry Andric    shared_ptr<T> atomic_exchange(shared_ptr<T>* p, shared_ptr<T> r);
8450b57cec5SDimitry Andrictemplate<class T>
8460b57cec5SDimitry Andric    shared_ptr<T>
8470b57cec5SDimitry Andric    atomic_exchange_explicit(shared_ptr<T>* p, shared_ptr<T> r, memory_order mo);
8480b57cec5SDimitry Andrictemplate<class T>
8490b57cec5SDimitry Andric    bool
8500b57cec5SDimitry Andric    atomic_compare_exchange_weak(shared_ptr<T>* p, shared_ptr<T>* v, shared_ptr<T> w);
8510b57cec5SDimitry Andrictemplate<class T>
8520b57cec5SDimitry Andric    bool
8530b57cec5SDimitry Andric    atomic_compare_exchange_strong( shared_ptr<T>* p, shared_ptr<T>* v, shared_ptr<T> w);
8540b57cec5SDimitry Andrictemplate<class T>
8550b57cec5SDimitry Andric    bool
8560b57cec5SDimitry Andric    atomic_compare_exchange_weak_explicit(shared_ptr<T>* p, shared_ptr<T>* v,
8570b57cec5SDimitry Andric                                          shared_ptr<T> w, memory_order success,
8580b57cec5SDimitry Andric                                          memory_order failure);
8590b57cec5SDimitry Andrictemplate<class T>
8600b57cec5SDimitry Andric    bool
8610b57cec5SDimitry Andric    atomic_compare_exchange_strong_explicit(shared_ptr<T>* p, shared_ptr<T>* v,
8620b57cec5SDimitry Andric                                            shared_ptr<T> w, memory_order success,
8630b57cec5SDimitry Andric                                            memory_order failure);
8640b57cec5SDimitry Andric// Hash support
8650b57cec5SDimitry Andrictemplate <class T> struct hash;
8660b57cec5SDimitry Andrictemplate <class T, class D> struct hash<unique_ptr<T, D> >;
8670b57cec5SDimitry Andrictemplate <class T> struct hash<shared_ptr<T> >;
8680b57cec5SDimitry Andric
8690b57cec5SDimitry Andrictemplate <class T, class Alloc>
8700b57cec5SDimitry Andric  inline constexpr bool uses_allocator_v = uses_allocator<T, Alloc>::value;
8710b57cec5SDimitry Andric
8725f757f3fSDimitry Andric// [allocator.uses.construction], uses-allocator construction
8735f757f3fSDimitry Andrictemplate<class T, class Alloc, class... Args>
8745f757f3fSDimitry Andric  constexpr auto uses_allocator_construction_args(const Alloc& alloc,             // since C++20
8755f757f3fSDimitry Andric                                                  Args&&... args) noexcept;
8765f757f3fSDimitry Andrictemplate<class T, class Alloc, class Tuple1, class Tuple2>
8775f757f3fSDimitry Andric  constexpr auto uses_allocator_construction_args(const Alloc& alloc,             // since C++20
8785f757f3fSDimitry Andric                                                  piecewise_construct_t,
8795f757f3fSDimitry Andric                                                  Tuple1&& x, Tuple2&& y) noexcept;
8805f757f3fSDimitry Andrictemplate<class T, class Alloc>
8815f757f3fSDimitry Andric  constexpr auto uses_allocator_construction_args(const Alloc& alloc) noexcept;   // since C++20
8825f757f3fSDimitry Andrictemplate<class T, class Alloc, class U, class V>
8835f757f3fSDimitry Andric  constexpr auto uses_allocator_construction_args(const Alloc& alloc,             // since C++20
8845f757f3fSDimitry Andric                                                  U&& u, V&& v) noexcept;
8855f757f3fSDimitry Andrictemplate<class T, class Alloc, class U, class V>
8865f757f3fSDimitry Andric  constexpr auto uses_allocator_construction_args(const Alloc& alloc,             // since C++23
8875f757f3fSDimitry Andric                                                  pair<U, V>& pr) noexcept;
8885f757f3fSDimitry Andrictemplate<class T, class Alloc, class U, class V>
8895f757f3fSDimitry Andric  constexpr auto uses_allocator_construction_args(const Alloc& alloc,             // since C++20
8905f757f3fSDimitry Andric                                                  const pair<U, V>& pr) noexcept;
8915f757f3fSDimitry Andrictemplate<class T, class Alloc, class U, class V>
8925f757f3fSDimitry Andric  constexpr auto uses_allocator_construction_args(const Alloc& alloc,             // since C++20
8935f757f3fSDimitry Andric                                                  pair<U, V>&& pr) noexcept;
8945f757f3fSDimitry Andrictemplate<class T, class Alloc, class U, class V>
8955f757f3fSDimitry Andric  constexpr auto uses_allocator_construction_args(const Alloc& alloc,             // since C++23
8965f757f3fSDimitry Andric                                                  const pair<U, V>&& pr) noexcept;
8975f757f3fSDimitry Andrictemplate<class T, class Alloc, pair-like P>
8985f757f3fSDimitry Andric  constexpr auto uses_allocator_construction_args(const Alloc& alloc,             // since C++20
8995f757f3fSDimitry Andric                                                  P&& p) noexcept;
9005f757f3fSDimitry Andrictemplate<class T, class Alloc, class U>
9015f757f3fSDimitry Andric  constexpr auto uses_allocator_construction_args(const Alloc& alloc,             // since C++20
9025f757f3fSDimitry Andric                                                  U&& u) noexcept;
9035f757f3fSDimitry Andrictemplate<class T, class Alloc, class... Args>
9045f757f3fSDimitry Andric  constexpr T make_obj_using_allocator(const Alloc& alloc, Args&&... args);       // since C++20
9055f757f3fSDimitry Andrictemplate<class T, class Alloc, class... Args>
9065f757f3fSDimitry Andric  constexpr T* uninitialized_construct_using_allocator(T* p,                      // since C++20
9075f757f3fSDimitry Andric                                                         const Alloc& alloc, Args&&... args);
9085f757f3fSDimitry Andric
90981ad6265SDimitry Andric// [ptr.align]
9100b57cec5SDimitry Andricvoid* align(size_t alignment, size_t size, void*& ptr, size_t& space);
9110b57cec5SDimitry Andric
91281ad6265SDimitry Andrictemplate<size_t N, class T>
91381ad6265SDimitry Andric[[nodiscard]] constexpr T* assume_aligned(T* ptr); // since C++20
91481ad6265SDimitry Andric
9150b57cec5SDimitry Andric}  // std
9160b57cec5SDimitry Andric
9170b57cec5SDimitry Andric*/
9180b57cec5SDimitry Andric
9195f757f3fSDimitry Andric// clang-format on
9205f757f3fSDimitry Andric
92181ad6265SDimitry Andric#include <__assert> // all public C++ headers provide the assertion handler
9220b57cec5SDimitry Andric#include <__config>
923fe6060f1SDimitry Andric#include <__memory/addressof.h>
924bdd1243dSDimitry Andric#include <__memory/align.h>
92581ad6265SDimitry Andric#include <__memory/allocate_at_least.h>
926fe6060f1SDimitry Andric#include <__memory/allocation_guard.h>
927fe6060f1SDimitry Andric#include <__memory/allocator.h>
928fe6060f1SDimitry Andric#include <__memory/allocator_arg_t.h>
929fe6060f1SDimitry Andric#include <__memory/allocator_traits.h>
93081ad6265SDimitry Andric#include <__memory/assume_aligned.h>
93181ad6265SDimitry Andric#include <__memory/auto_ptr.h>
932fe6060f1SDimitry Andric#include <__memory/compressed_pair.h>
9330eae32dcSDimitry Andric#include <__memory/concepts.h>
934fe6060f1SDimitry Andric#include <__memory/construct_at.h>
935fe6060f1SDimitry Andric#include <__memory/pointer_traits.h>
93604eeddc0SDimitry Andric#include <__memory/ranges_construct_at.h>
9370eae32dcSDimitry Andric#include <__memory/ranges_uninitialized_algorithms.h>
938fe6060f1SDimitry Andric#include <__memory/raw_storage_iterator.h>
939fe6060f1SDimitry Andric#include <__memory/shared_ptr.h>
940fe6060f1SDimitry Andric#include <__memory/temporary_buffer.h>
941fe6060f1SDimitry Andric#include <__memory/uninitialized_algorithms.h>
942fe6060f1SDimitry Andric#include <__memory/unique_ptr.h>
943fe6060f1SDimitry Andric#include <__memory/uses_allocator.h>
944bdd1243dSDimitry Andric#include <__memory/uses_allocator_construction.h>
9450b57cec5SDimitry Andric#include <version>
9460b57cec5SDimitry Andric
94781ad6265SDimitry Andric// standard-mandated includes
948bdd1243dSDimitry Andric
949bdd1243dSDimitry Andric// [memory.syn]
95081ad6265SDimitry Andric#include <compare>
95181ad6265SDimitry Andric
9520b57cec5SDimitry Andric#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
9530b57cec5SDimitry Andric#  pragma GCC system_header
9540b57cec5SDimitry Andric#endif
9550b57cec5SDimitry Andric
956bdd1243dSDimitry Andric#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
95706c3fb27SDimitry Andric#  include <atomic>
958bdd1243dSDimitry Andric#  include <concepts>
959bdd1243dSDimitry Andric#  include <cstddef>
960bdd1243dSDimitry Andric#  include <cstdint>
96106c3fb27SDimitry Andric#  include <cstdlib>
962bdd1243dSDimitry Andric#  include <cstring>
963bdd1243dSDimitry Andric#  include <iosfwd>
964bdd1243dSDimitry Andric#  include <iterator>
965bdd1243dSDimitry Andric#  include <new>
966bdd1243dSDimitry Andric#  include <stdexcept>
967bdd1243dSDimitry Andric#  include <tuple>
968bdd1243dSDimitry Andric#  include <type_traits>
969bdd1243dSDimitry Andric#  include <typeinfo>
970bdd1243dSDimitry Andric#  include <utility>
971bdd1243dSDimitry Andric#endif
972bdd1243dSDimitry Andric
9730b57cec5SDimitry Andric#endif // _LIBCPP_MEMORY
974