xref: /freebsd/contrib/llvm-project/libcxx/include/memory (revision 0fca6ea1d4eea4c934cfff25ac9ee8ad6fe95583)
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
91*0fca6ea1SDimitry Andric    [[nodiscard]] static constexpr allocation_result<pointer, size_type>
92*0fca6ea1SDimitry Andric      allocate_at_least(Alloc& a, size_type n);                                 // Since C++23
93*0fca6ea1SDimitry Andric
94e8d8bef9SDimitry Andric    static void deallocate(allocator_type& a, pointer p, size_type n) noexcept; // constexpr in C++20
950b57cec5SDimitry Andric
960b57cec5SDimitry Andric    template <class T, class... Args>
97e8d8bef9SDimitry Andric    static void construct(allocator_type& a, T* p, Args&&... args); // constexpr in C++20
980b57cec5SDimitry Andric
990b57cec5SDimitry Andric    template <class T>
100e8d8bef9SDimitry Andric    static void destroy(allocator_type& a, T* p); // constexpr in C++20
1010b57cec5SDimitry Andric
102e8d8bef9SDimitry Andric    static size_type max_size(const allocator_type& a); // noexcept in C++14, constexpr in C++20
103e8d8bef9SDimitry Andric    static allocator_type select_on_container_copy_construction(const allocator_type& a); // constexpr in C++20
1040b57cec5SDimitry Andric};
1050b57cec5SDimitry Andric
106*0fca6ea1SDimitry Andrictemplate<class Pointer, class SizeType = size_t>
10781ad6265SDimitry Andricstruct allocation_result {
10881ad6265SDimitry Andric    Pointer ptr;
109*0fca6ea1SDimitry Andric    SizeType count;
110*0fca6ea1SDimitry Andric}; // Since C++23
11181ad6265SDimitry Andric
1120b57cec5SDimitry Andrictemplate <>
11323408297SDimitry Andricclass allocator<void> // removed in C++20
1140b57cec5SDimitry Andric{
1150b57cec5SDimitry Andricpublic:
116fe6060f1SDimitry Andric    typedef void*                                 pointer;
117fe6060f1SDimitry Andric    typedef const void*                           const_pointer;
118fe6060f1SDimitry Andric    typedef void                                  value_type;
1190b57cec5SDimitry Andric
120fe6060f1SDimitry Andric    template <class _Up> struct rebind {typedef allocator<_Up> other;};
1210b57cec5SDimitry Andric};
1220b57cec5SDimitry Andric
1230b57cec5SDimitry Andrictemplate <class T>
1240b57cec5SDimitry Andricclass allocator
1250b57cec5SDimitry Andric{
1260b57cec5SDimitry Andricpublic:
127e8d8bef9SDimitry Andric    typedef size_t    size_type;
128e8d8bef9SDimitry Andric    typedef ptrdiff_t difference_type;
1295ffd83dbSDimitry Andric    typedef T*        pointer;                           // deprecated in C++17, removed in C++20
1305ffd83dbSDimitry Andric    typedef const T*  const_pointer;                     // deprecated in C++17, removed in C++20
1315ffd83dbSDimitry Andric    typedef typename add_lvalue_reference<T>::type
1325ffd83dbSDimitry Andric                      reference;                         // deprecated in C++17, removed in C++20
1335ffd83dbSDimitry Andric    typedef typename add_lvalue_reference<const T>::type
1345ffd83dbSDimitry Andric                      const_reference;                   // deprecated in C++17, removed in C++20
1355ffd83dbSDimitry Andric
1360b57cec5SDimitry Andric    typedef T         value_type;
1370b57cec5SDimitry Andric
1385ffd83dbSDimitry Andric    template <class U> struct rebind {typedef allocator<U> other;}; // deprecated in C++17, removed in C++20
1395ffd83dbSDimitry Andric
1405ffd83dbSDimitry Andric    typedef true_type propagate_on_container_move_assignment;
1417a6dacacSDimitry Andric    typedef true_type is_always_equal;                   // Deprecated in C++23, removed in C++26
1420b57cec5SDimitry Andric
1430b57cec5SDimitry Andric    constexpr allocator() noexcept;                      // constexpr in C++20
1440b57cec5SDimitry Andric    constexpr allocator(const allocator&) noexcept;      // constexpr in C++20
1450b57cec5SDimitry Andric    template <class U>
1460b57cec5SDimitry Andric      constexpr allocator(const allocator<U>&) noexcept; // constexpr in C++20
147e8d8bef9SDimitry Andric    ~allocator();                                        // constexpr in C++20
1485ffd83dbSDimitry Andric    pointer address(reference x) const noexcept;             // deprecated in C++17, removed in C++20
1495ffd83dbSDimitry Andric    const_pointer address(const_reference x) const noexcept; // deprecated in C++17, removed in C++20
1505ffd83dbSDimitry Andric    T* allocate(size_t n, const void* hint);          // deprecated in C++17, removed in C++20
151e8d8bef9SDimitry Andric    T* allocate(size_t n);                              // constexpr in C++20
152e8d8bef9SDimitry Andric    void deallocate(T* p, size_t n) noexcept;           // constexpr in C++20
1535ffd83dbSDimitry Andric    size_type max_size() const noexcept;              // deprecated in C++17, removed in C++20
1540b57cec5SDimitry Andric    template<class U, class... Args>
1555ffd83dbSDimitry Andric        void construct(U* p, Args&&... args);         // deprecated in C++17, removed in C++20
1560b57cec5SDimitry Andric    template <class U>
1575ffd83dbSDimitry Andric        void destroy(U* p);                           // deprecated in C++17, removed in C++20
1580b57cec5SDimitry Andric};
1590b57cec5SDimitry Andric
1600b57cec5SDimitry Andrictemplate <class T, class U>
161e8d8bef9SDimitry Andricbool operator==(const allocator<T>&, const allocator<U>&) noexcept; // constexpr in C++20
1620b57cec5SDimitry Andric
1630b57cec5SDimitry Andrictemplate <class T, class U>
16406c3fb27SDimitry Andricbool operator!=(const allocator<T>&, const allocator<U>&) noexcept; // removed in C++20
1650b57cec5SDimitry Andric
1660b57cec5SDimitry Andrictemplate <class OutputIterator, class T>
167fe6060f1SDimitry Andricclass raw_storage_iterator // deprecated in C++17, removed in C++20
168fe6060f1SDimitry Andric    : public iterator<output_iterator_tag, void, void, void, void> // until C++17
1690b57cec5SDimitry Andric{
1700b57cec5SDimitry Andricpublic:
171fe6060f1SDimitry Andric    typedef output_iterator_tag iterator_category;
172fe6060f1SDimitry Andric    typedef void                value_type;
173fe6060f1SDimitry Andric    typedef void                difference_type; // until C++20
174fe6060f1SDimitry Andric    typedef ptrdiff_t           difference_type; // since C++20
175fe6060f1SDimitry Andric    typedef void                pointer;
176fe6060f1SDimitry Andric    typedef void                reference;
177fe6060f1SDimitry Andric
1780b57cec5SDimitry Andric    explicit raw_storage_iterator(OutputIterator x);
1790b57cec5SDimitry Andric    raw_storage_iterator& operator*();
1800b57cec5SDimitry Andric    raw_storage_iterator& operator=(const T& element);
1810b57cec5SDimitry Andric    raw_storage_iterator& operator++();
1820b57cec5SDimitry Andric    raw_storage_iterator  operator++(int);
1830b57cec5SDimitry Andric};
1840b57cec5SDimitry Andric
1850b57cec5SDimitry Andrictemplate <class T> pair<T*,ptrdiff_t> get_temporary_buffer(ptrdiff_t n) noexcept;
1860b57cec5SDimitry Andrictemplate <class T> void               return_temporary_buffer(T* p) noexcept;
1870b57cec5SDimitry Andric
1880b57cec5SDimitry Andrictemplate <class T> T* addressof(T& r) noexcept;
1890b57cec5SDimitry Andrictemplate <class T> T* addressof(const T&& r) noexcept = delete;
1900b57cec5SDimitry Andric
1910b57cec5SDimitry Andrictemplate <class InputIterator, class ForwardIterator>
1920b57cec5SDimitry AndricForwardIterator
1930b57cec5SDimitry Andricuninitialized_copy(InputIterator first, InputIterator last, ForwardIterator result);
1940b57cec5SDimitry Andric
19504eeddc0SDimitry Andricnamespace ranges {
19604eeddc0SDimitry Andric
19704eeddc0SDimitry Andrictemplate<class InputIterator, class OutputIterator>
19804eeddc0SDimitry Andricusing uninitialized_copy_result = in_out_result<InputIterator, OutputIterator>; // since C++20
19904eeddc0SDimitry Andric
20004eeddc0SDimitry Andrictemplate<input_iterator InputIterator, sentinel-for<InputIterator> Sentinel1, nothrow-forward-iterator OutputIterator, nothrow-sentinel-for<OutputIterator> Sentinel2>
20104eeddc0SDimitry Andric  requires constructible_from<iter_value_t<OutputIterator>, iter_reference_t<InputIterator>>
20204eeddc0SDimitry Andricuninitialized_copy_result<InputIterator, OutputIterator>
20304eeddc0SDimitry Andricuninitialized_copy(InputIterator ifirst, Sentinel1 ilast, OutputIterator ofirst, Sentinel2 olast); // since C++20
20404eeddc0SDimitry Andric
20504eeddc0SDimitry Andrictemplate<input_range InputRange, nothrow-forward-range OutputRange>
20604eeddc0SDimitry Andric  requires constructible_from<range_value_t<OutputRange>, range_reference_t<InputRange>>
20704eeddc0SDimitry Andricuninitialized_copy_result<borrowed_iterator_t<InputRange>, borrowed_iterator_t<OutputRange>>
20804eeddc0SDimitry Andricuninitialized_copy(InputRange&& in_range, OutputRange&& out_range); // since C++20
20904eeddc0SDimitry Andric
21004eeddc0SDimitry Andric}
21104eeddc0SDimitry Andric
2120b57cec5SDimitry Andrictemplate <class InputIterator, class Size, class ForwardIterator>
2130b57cec5SDimitry AndricForwardIterator
2140b57cec5SDimitry Andricuninitialized_copy_n(InputIterator first, Size n, ForwardIterator result);
2150b57cec5SDimitry Andric
21604eeddc0SDimitry Andricnamespace ranges {
21704eeddc0SDimitry Andric
21804eeddc0SDimitry Andrictemplate<class InputIterator, class OutputIterator>
21904eeddc0SDimitry Andricusing uninitialized_copy_n_result = in_out_result<InputIterator, OutputIterator>; // since C++20
22004eeddc0SDimitry Andric
22104eeddc0SDimitry Andrictemplate<input_iterator InputIterator, nothrow-forward-iterator OutputIterator, nothrow-sentinel-for<OutputIterator> Sentinel>
22204eeddc0SDimitry Andric  requires constructible_from<iter_value_t<OutputIterator>, iter_reference_t<InputIterator>>
22304eeddc0SDimitry Andricuninitialized_copy_n_result<InputIterator, OutputIterator>
22404eeddc0SDimitry Andricuninitialized_copy_n(InputIterator ifirst, iter_difference_t<InputIterator> n, OutputIterator ofirst, Sentinel olast); // since C++20
22504eeddc0SDimitry Andric
22604eeddc0SDimitry Andric}
22704eeddc0SDimitry Andric
2280b57cec5SDimitry Andrictemplate <class ForwardIterator, class T>
2290b57cec5SDimitry Andricvoid uninitialized_fill(ForwardIterator first, ForwardIterator last, const T& x);
2300b57cec5SDimitry Andric
23104eeddc0SDimitry Andricnamespace ranges {
23204eeddc0SDimitry Andric
2330eae32dcSDimitry Andrictemplate <nothrow-forward-iterator ForwardIterator, nothrow-sentinel-for<ForwardIterator> Sentinel, class T>
2340eae32dcSDimitry Andric  requires constructible_from<iter_value_t<ForwardIterator>, const T&>
23504eeddc0SDimitry AndricForwardIterator uninitialized_fill(ForwardIterator first, Sentinel last, const T& x); // since C++20
2360eae32dcSDimitry Andric
2370eae32dcSDimitry Andrictemplate <nothrow-forward-range ForwardRange, class T>
2380eae32dcSDimitry Andric  requires constructible_from<range_value_t<ForwardRange>, const T&>
23904eeddc0SDimitry Andricborrowed_iterator_t<ForwardRange> uninitialized_fill(ForwardRange&& range, const T& x); // since C++20
24004eeddc0SDimitry Andric
24104eeddc0SDimitry Andric}
2420eae32dcSDimitry Andric
2430b57cec5SDimitry Andrictemplate <class ForwardIterator, class Size, class T>
2440b57cec5SDimitry AndricForwardIterator
2450b57cec5SDimitry Andricuninitialized_fill_n(ForwardIterator first, Size n, const T& x);
2460b57cec5SDimitry Andric
24704eeddc0SDimitry Andricnamespace ranges {
24804eeddc0SDimitry Andric
2490eae32dcSDimitry Andrictemplate <nothrow-forward-iterator ForwardIterator, class T>
2500eae32dcSDimitry Andric  requires constructible_from<iter_value_t<ForwardIterator>, const T&>
25104eeddc0SDimitry AndricForwardIterator uninitialized_fill_n(ForwardIterator first, iter_difference_t<ForwardIterator> n); // since C++20
25204eeddc0SDimitry Andric
25304eeddc0SDimitry Andric}
2540eae32dcSDimitry Andric
255e8d8bef9SDimitry Andrictemplate <class T, class ...Args>
256e8d8bef9SDimitry Andricconstexpr T* construct_at(T* location, Args&& ...args); // since C++20
257e8d8bef9SDimitry Andric
25804eeddc0SDimitry Andricnamespace ranges {
25904eeddc0SDimitry Andric  template<class T, class... Args>
26004eeddc0SDimitry Andric    constexpr T* construct_at(T* location, Args&&... args); // since C++20
26104eeddc0SDimitry Andric}
26204eeddc0SDimitry Andric
2630b57cec5SDimitry Andrictemplate <class T>
264e8d8bef9SDimitry Andricvoid destroy_at(T* location); // constexpr in C++20
2650b57cec5SDimitry Andric
26604eeddc0SDimitry Andricnamespace ranges {
26704eeddc0SDimitry Andric  template<destructible T>
26804eeddc0SDimitry Andric    constexpr void destroy_at(T* location) noexcept; // since C++20
26904eeddc0SDimitry Andric}
27004eeddc0SDimitry Andric
2710b57cec5SDimitry Andrictemplate <class ForwardIterator>
272e8d8bef9SDimitry Andricvoid destroy(ForwardIterator first, ForwardIterator last); // constexpr in C++20
2730b57cec5SDimitry Andric
27404eeddc0SDimitry Andricnamespace ranges {
27504eeddc0SDimitry Andric  template<nothrow-input-iterator InputIterator, nothrow-sentinel-for<InputIterator> Sentinel>
27604eeddc0SDimitry Andric    requires destructible<iter_value_t<InputIterator>>
27704eeddc0SDimitry Andric    constexpr InputIterator destroy(InputIterator first, Sentinel last) noexcept; // since C++20
27804eeddc0SDimitry Andric  template<nothrow-input-range InputRange>
27904eeddc0SDimitry Andric    requires destructible<range_value_t<InputRange>>
28004eeddc0SDimitry Andric    constexpr borrowed_iterator_t<InputRange> destroy(InputRange&& range) noexcept; // since C++20
28104eeddc0SDimitry Andric}
28204eeddc0SDimitry Andric
2830b57cec5SDimitry Andrictemplate <class ForwardIterator, class Size>
284e8d8bef9SDimitry AndricForwardIterator destroy_n(ForwardIterator first, Size n); // constexpr in C++20
2850b57cec5SDimitry Andric
28604eeddc0SDimitry Andricnamespace ranges {
28704eeddc0SDimitry Andric  template<nothrow-input-iterator InputIterator>
28804eeddc0SDimitry Andric    requires destructible<iter_value_t<InputIterator>>
28904eeddc0SDimitry Andric    constexpr InputIterator destroy_n(InputIterator first, iter_difference_t<InputIterator> n) noexcept; // since C++20
29004eeddc0SDimitry Andric}
29104eeddc0SDimitry Andric
2920b57cec5SDimitry Andrictemplate <class InputIterator, class ForwardIterator>
2930b57cec5SDimitry Andric ForwardIterator uninitialized_move(InputIterator first, InputIterator last, ForwardIterator result);
2940b57cec5SDimitry Andric
29504eeddc0SDimitry Andricnamespace ranges {
29604eeddc0SDimitry Andric
29704eeddc0SDimitry Andrictemplate<class InputIterator, class OutputIterator>
29804eeddc0SDimitry Andricusing uninitialized_move_result = in_out_result<InputIterator, OutputIterator>; // since C++20
29904eeddc0SDimitry Andric
30004eeddc0SDimitry Andrictemplate <input_iterator InputIterator, sentinel_for<InputIterator> Sentinel1, nothrow-forward-iterator OutputIterator, nothrow-sentinel-for<O> Sentinel2>
30104eeddc0SDimitry Andric  requires constructible_from<iter_value_t<OutputIterator>, iter_rvalue_reference_t<InputIterator>>
30204eeddc0SDimitry Andricuninitialized_move_result<InputIterator, OutputIterator>
30304eeddc0SDimitry Andricuninitialized_move(InputIterator ifirst, Sentinel1 ilast, OutputIterator ofirst, Sentinel2 olast); // since C++20
30404eeddc0SDimitry Andric
30504eeddc0SDimitry Andrictemplate<input_range InputRange, nothrow-forward-range OutputRange>
30604eeddc0SDimitry Andric  requires constructible_from<range_value_t<OutputRange>, range_rvalue_reference_t<InputRange>>
30704eeddc0SDimitry Andricuninitialized_move_result<borrowed_iterator_t<InputRange>, borrowed_iterator_t<OutputRange>>
30804eeddc0SDimitry Andricuninitialized_move(InputRange&& in_range, OutputRange&& out_range); // since C++20
30904eeddc0SDimitry Andric
31004eeddc0SDimitry Andric}
31104eeddc0SDimitry Andric
3120b57cec5SDimitry Andrictemplate <class InputIterator, class Size, class ForwardIterator>
3130b57cec5SDimitry Andric pair<InputIterator,ForwardIterator> uninitialized_move_n(InputIterator first, Size n, ForwardIterator result);
3140b57cec5SDimitry Andric
31504eeddc0SDimitry Andricnamespace ranges {
31604eeddc0SDimitry Andric
31704eeddc0SDimitry Andrictemplate<class InputIterator, class OutputIterator>
31804eeddc0SDimitry Andricusing uninitialized_move_n_result = in_out_result<InputIterator, OutputIterator>; // since C++20
31904eeddc0SDimitry Andric
32004eeddc0SDimitry Andrictemplate<input_iterator InputIterator, nothrow-forward-iterator OutputIterator, nothrow-sentinel-for<OutputIterator> Sentinel>
32104eeddc0SDimitry Andric  requires constructible_from<iter_value_t<OutputIterator>, iter_rvalue_reference_t<InputIterator>>
32204eeddc0SDimitry Andricuninitialized_move_n_result<InputIterator, OutputIterator>
32304eeddc0SDimitry Andricuninitialized_move_n(InputIterator ifirst, iter_difference_t<InputIterator> n, OutputIterator ofirst, Sentinel olast); // since C++20
32404eeddc0SDimitry Andric
32504eeddc0SDimitry Andric}
32604eeddc0SDimitry Andric
3270b57cec5SDimitry Andrictemplate <class ForwardIterator>
3280b57cec5SDimitry Andric void uninitialized_value_construct(ForwardIterator first, ForwardIterator last);
3290b57cec5SDimitry Andric
33004eeddc0SDimitry Andricnamespace ranges {
33104eeddc0SDimitry Andric
3320eae32dcSDimitry Andrictemplate <nothrow-forward-iterator ForwardIterator, nothrow-sentinel-for<ForwardIterator> Sentinel>
3330eae32dcSDimitry Andric  requires default_initializable<iter_value_t<ForwardIterator>>
33404eeddc0SDimitry Andric ForwardIterator uninitialized_value_construct(ForwardIterator first, Sentinel last); // since C++20
3350eae32dcSDimitry Andric
3360eae32dcSDimitry Andrictemplate <nothrow-forward-range ForwardRange>
3370eae32dcSDimitry Andric  requires default_initializable<range_value_t<ForwardRange>>
33804eeddc0SDimitry Andric borrowed_iterator_t<ForwardRange> uninitialized_value_construct(ForwardRange&& r); // since C++20
33904eeddc0SDimitry Andric
34004eeddc0SDimitry Andric}
3410eae32dcSDimitry Andric
3420b57cec5SDimitry Andrictemplate <class ForwardIterator, class Size>
3430b57cec5SDimitry Andric ForwardIterator uninitialized_value_construct_n(ForwardIterator first, Size n);
3440b57cec5SDimitry Andric
34504eeddc0SDimitry Andricnamespace ranges {
34604eeddc0SDimitry Andric
3470eae32dcSDimitry Andrictemplate <nothrow-forward-iterator ForwardIterator>
3480eae32dcSDimitry Andric  requires default_initializable<iter_value_t<ForwardIterator>>
34904eeddc0SDimitry Andric ForwardIterator uninitialized_value_construct_n(ForwardIterator first, iter_difference_t<ForwardIterator> n); // since C++20
35004eeddc0SDimitry Andric
35104eeddc0SDimitry Andric}
3520eae32dcSDimitry Andric
3530b57cec5SDimitry Andrictemplate <class ForwardIterator>
3540b57cec5SDimitry Andric void uninitialized_default_construct(ForwardIterator first, ForwardIterator last);
3550b57cec5SDimitry Andric
35604eeddc0SDimitry Andricnamespace ranges {
35704eeddc0SDimitry Andric
3580eae32dcSDimitry Andrictemplate <nothrow-forward-iterator ForwardIterator, nothrow-sentinel-for<ForwardIterator> Sentinel>
3590eae32dcSDimitry Andric  requires default_initializable<iter_value_t<ForwardIterator>>
36004eeddc0SDimitry Andric ForwardIterator uninitialized_default_construct(ForwardIterator first, Sentinel last); // since C++20
3610eae32dcSDimitry Andric
3620eae32dcSDimitry Andrictemplate <nothrow-forward-range ForwardRange>
3630eae32dcSDimitry Andric  requires default_initializable<range_value_t<ForwardRange>>
36404eeddc0SDimitry Andric borrowed_iterator_t<ForwardRange> uninitialized_default_construct(ForwardRange&& r); // since C++20
36504eeddc0SDimitry Andric
36604eeddc0SDimitry Andric}
3670eae32dcSDimitry Andric
3680b57cec5SDimitry Andrictemplate <class ForwardIterator, class Size>
3690b57cec5SDimitry Andric ForwardIterator uninitialized_default_construct_n(ForwardIterator first, Size n);
3700b57cec5SDimitry Andric
37104eeddc0SDimitry Andricnamespace ranges {
37204eeddc0SDimitry Andric
3730eae32dcSDimitry Andrictemplate <nothrow-forward-iterator ForwardIterator>
3740eae32dcSDimitry Andric  requires default_initializable<iter_value_t<ForwardIterator>>
37504eeddc0SDimitry Andric ForwardIterator uninitialized_default_construct_n(ForwardIterator first, iter_difference_t<ForwardIterator> n); // since C++20
37604eeddc0SDimitry Andric
37704eeddc0SDimitry Andric}
3780eae32dcSDimitry Andric
3790b57cec5SDimitry Andrictemplate <class Y> struct auto_ptr_ref {};      // deprecated in C++11, removed in C++17
3800b57cec5SDimitry Andric
3810b57cec5SDimitry Andrictemplate<class X>
3820b57cec5SDimitry Andricclass auto_ptr                                  // deprecated in C++11, removed in C++17
3830b57cec5SDimitry Andric{
3840b57cec5SDimitry Andricpublic:
3850b57cec5SDimitry Andric    typedef X element_type;
3860b57cec5SDimitry Andric
3870b57cec5SDimitry Andric    explicit auto_ptr(X* p =0) throw();
3880b57cec5SDimitry Andric    auto_ptr(auto_ptr&) throw();
3890b57cec5SDimitry Andric    template<class Y> auto_ptr(auto_ptr<Y>&) throw();
3900b57cec5SDimitry Andric    auto_ptr& operator=(auto_ptr&) throw();
3910b57cec5SDimitry Andric    template<class Y> auto_ptr& operator=(auto_ptr<Y>&) throw();
3920b57cec5SDimitry Andric    auto_ptr& operator=(auto_ptr_ref<X> r) throw();
3930b57cec5SDimitry Andric    ~auto_ptr() throw();
3940b57cec5SDimitry Andric
3950b57cec5SDimitry Andric    typename add_lvalue_reference<X>::type operator*() const throw();
3960b57cec5SDimitry Andric    X* operator->() const throw();
3970b57cec5SDimitry Andric    X* get() const throw();
3980b57cec5SDimitry Andric    X* release() throw();
3990b57cec5SDimitry Andric    void reset(X* p =0) throw();
4000b57cec5SDimitry Andric
4010b57cec5SDimitry Andric    auto_ptr(auto_ptr_ref<X>) throw();
4020b57cec5SDimitry Andric    template<class Y> operator auto_ptr_ref<Y>() throw();
4030b57cec5SDimitry Andric    template<class Y> operator auto_ptr<Y>() throw();
4040b57cec5SDimitry Andric};
4050b57cec5SDimitry Andric
4060b57cec5SDimitry Andrictemplate <class T>
4070b57cec5SDimitry Andricstruct default_delete
4080b57cec5SDimitry Andric{
4090b57cec5SDimitry Andric    constexpr default_delete() noexcept = default;
410bdd1243dSDimitry Andric    template <class U> constexpr default_delete(const default_delete<U>&) noexcept; // constexpr since C++23
4110b57cec5SDimitry Andric
412bdd1243dSDimitry Andric    constexpr void operator()(T*) const noexcept;                                   // constexpr since C++23
4130b57cec5SDimitry Andric};
4140b57cec5SDimitry Andric
4150b57cec5SDimitry Andrictemplate <class T>
4160b57cec5SDimitry Andricstruct default_delete<T[]>
4170b57cec5SDimitry Andric{
4180b57cec5SDimitry Andric    constexpr default_delete() noexcept = default;
419bdd1243dSDimitry Andric    template <class U> constexpr default_delete(const default_delete <U[]>&) noexcept; // constexpr since C++23
420bdd1243dSDimitry Andric    constexpr void operator()(T*) const noexcept;                                      // constexpr since C++23
4210b57cec5SDimitry Andric    template <class U> void operator()(U*) const = delete;
4220b57cec5SDimitry Andric};
4230b57cec5SDimitry Andric
4240b57cec5SDimitry Andrictemplate <class T, class D = default_delete<T>>
4250b57cec5SDimitry Andricclass unique_ptr
4260b57cec5SDimitry Andric{
4270b57cec5SDimitry Andricpublic:
4280b57cec5SDimitry Andric    typedef see below pointer;
4290b57cec5SDimitry Andric    typedef T element_type;
4300b57cec5SDimitry Andric    typedef D deleter_type;
4310b57cec5SDimitry Andric
4320b57cec5SDimitry Andric    // constructors
4330b57cec5SDimitry Andric    constexpr unique_ptr() noexcept;
434bdd1243dSDimitry Andric    constexpr explicit unique_ptr(pointer p) noexcept;           // constexpr since C++23
435bdd1243dSDimitry Andric    constexpr unique_ptr(pointer p, see below d1) noexcept;      // constexpr since C++23
436bdd1243dSDimitry Andric    constexpr unique_ptr(pointer p, see below d2) noexcept;      // constexpr since C++23
437bdd1243dSDimitry Andric    constexpr unique_ptr(unique_ptr&& u) noexcept;               // constexpr since C++23
438bdd1243dSDimitry Andric    constexpr unique_ptr(nullptr_t) noexcept : unique_ptr() { }
4390b57cec5SDimitry Andric    template <class U, class E>
440bdd1243dSDimitry Andric        constexpr unique_ptr(unique_ptr<U, E>&& u) noexcept;     // constexpr since C++23
4410b57cec5SDimitry Andric    template <class U>
4420b57cec5SDimitry Andric        unique_ptr(auto_ptr<U>&& u) noexcept;                    // removed in C++17
4430b57cec5SDimitry Andric
4440b57cec5SDimitry Andric    // destructor
445bdd1243dSDimitry Andric    constexpr ~unique_ptr();                                     // constexpr since C++23
4460b57cec5SDimitry Andric
4470b57cec5SDimitry Andric    // assignment
448bdd1243dSDimitry Andric    constexpr unique_ptr& operator=(unique_ptr&& u) noexcept;                         // constexpr since C++23
449bdd1243dSDimitry Andric    template <class U, class E>
450bdd1243dSDimitry Andric    constexpr unique_ptr& operator=(unique_ptr<U, E>&& u) noexcept;                   // constexpr since C++23
451bdd1243dSDimitry Andric    constexpr unique_ptr& operator=(nullptr_t) noexcept;                              // constexpr since C++23
4520b57cec5SDimitry Andric
4530b57cec5SDimitry Andric    // observers
454*0fca6ea1SDimitry Andric    constexpr
455*0fca6ea1SDimitry Andric    add_lvalue_reference<T>::type operator*() const noexcept(see below);              // 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
915*0fca6ea1SDimitry Andric// [out.ptr.t], class template out_ptr_t
916*0fca6ea1SDimitry Andrictemplate<class Smart, class Pointer, class... Args>
917*0fca6ea1SDimitry Andric  class out_ptr_t;                                          // since c++23
918*0fca6ea1SDimitry Andric
919*0fca6ea1SDimitry Andric// [out.ptr], function template out_ptr
920*0fca6ea1SDimitry Andrictemplate<class Pointer = void, class Smart, class... Args>
921*0fca6ea1SDimitry Andric  auto out_ptr(Smart& s, Args&&... args);                   // since c++23
922*0fca6ea1SDimitry Andric
923*0fca6ea1SDimitry Andric// [inout.ptr.t], class template inout_ptr_t
924*0fca6ea1SDimitry Andrictemplate<class Smart, class Pointer, class... Args>
925*0fca6ea1SDimitry Andric  class inout_ptr_t;                                        // since c++23
926*0fca6ea1SDimitry Andric
927*0fca6ea1SDimitry Andric// [inout.ptr], function template inout_ptr
928*0fca6ea1SDimitry Andrictemplate<class Pointer = void, class Smart, class... Args>
929*0fca6ea1SDimitry Andric  auto inout_ptr(Smart& s, Args&&... args);                 // since c++23
930*0fca6ea1SDimitry Andric
9310b57cec5SDimitry Andric}  // std
9320b57cec5SDimitry Andric
9330b57cec5SDimitry Andric*/
9340b57cec5SDimitry Andric
9355f757f3fSDimitry Andric// clang-format on
9365f757f3fSDimitry Andric
9370b57cec5SDimitry Andric#include <__config>
938fe6060f1SDimitry Andric#include <__memory/addressof.h>
939bdd1243dSDimitry Andric#include <__memory/align.h>
940fe6060f1SDimitry Andric#include <__memory/allocator.h>
941fe6060f1SDimitry Andric#include <__memory/allocator_arg_t.h>
942fe6060f1SDimitry Andric#include <__memory/allocator_traits.h>
94381ad6265SDimitry Andric#include <__memory/auto_ptr.h>
944*0fca6ea1SDimitry Andric#include <__memory/inout_ptr.h>
945*0fca6ea1SDimitry Andric#include <__memory/out_ptr.h>
946fe6060f1SDimitry Andric#include <__memory/pointer_traits.h>
947fe6060f1SDimitry Andric#include <__memory/raw_storage_iterator.h>
948fe6060f1SDimitry Andric#include <__memory/shared_ptr.h>
949fe6060f1SDimitry Andric#include <__memory/temporary_buffer.h>
950fe6060f1SDimitry Andric#include <__memory/uninitialized_algorithms.h>
951fe6060f1SDimitry Andric#include <__memory/unique_ptr.h>
952fe6060f1SDimitry Andric#include <__memory/uses_allocator.h>
9530b57cec5SDimitry Andric
95481ad6265SDimitry Andric// standard-mandated includes
955bdd1243dSDimitry Andric
956*0fca6ea1SDimitry Andric#if _LIBCPP_STD_VER >= 17
957*0fca6ea1SDimitry Andric#  include <__memory/construct_at.h>
958*0fca6ea1SDimitry Andric#endif
959*0fca6ea1SDimitry Andric
960*0fca6ea1SDimitry Andric#if _LIBCPP_STD_VER >= 20
961*0fca6ea1SDimitry Andric#  include <__memory/assume_aligned.h>
962*0fca6ea1SDimitry Andric#  include <__memory/concepts.h>
963*0fca6ea1SDimitry Andric#  include <__memory/ranges_construct_at.h>
964*0fca6ea1SDimitry Andric#  include <__memory/ranges_uninitialized_algorithms.h>
965*0fca6ea1SDimitry Andric#  include <__memory/uses_allocator_construction.h>
966*0fca6ea1SDimitry Andric#endif
967*0fca6ea1SDimitry Andric
968*0fca6ea1SDimitry Andric#if _LIBCPP_STD_VER >= 23
969*0fca6ea1SDimitry Andric#  include <__memory/allocate_at_least.h>
970*0fca6ea1SDimitry Andric#endif
971*0fca6ea1SDimitry Andric
972*0fca6ea1SDimitry Andric#include <version>
973*0fca6ea1SDimitry Andric
974bdd1243dSDimitry Andric// [memory.syn]
97581ad6265SDimitry Andric#include <compare>
97681ad6265SDimitry Andric
9770b57cec5SDimitry Andric#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
9780b57cec5SDimitry Andric#  pragma GCC system_header
9790b57cec5SDimitry Andric#endif
9800b57cec5SDimitry Andric
981bdd1243dSDimitry Andric#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
98206c3fb27SDimitry Andric#  include <atomic>
983bdd1243dSDimitry Andric#  include <concepts>
984bdd1243dSDimitry Andric#  include <cstddef>
985bdd1243dSDimitry Andric#  include <cstdint>
98606c3fb27SDimitry Andric#  include <cstdlib>
987bdd1243dSDimitry Andric#  include <cstring>
988bdd1243dSDimitry Andric#  include <iosfwd>
989bdd1243dSDimitry Andric#  include <iterator>
990bdd1243dSDimitry Andric#  include <new>
991bdd1243dSDimitry Andric#  include <stdexcept>
992bdd1243dSDimitry Andric#  include <tuple>
993bdd1243dSDimitry Andric#  include <type_traits>
994bdd1243dSDimitry Andric#  include <typeinfo>
995bdd1243dSDimitry Andric#  include <utility>
996bdd1243dSDimitry Andric#endif
997bdd1243dSDimitry Andric
9980b57cec5SDimitry Andric#endif // _LIBCPP_MEMORY
999