xref: /freebsd/contrib/llvm-project/libcxx/include/memory (revision bdd1243df58e60e85101c09001d9812a789b6bc4)
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
130b57cec5SDimitry Andric/*
140b57cec5SDimitry Andric    memory synopsis
150b57cec5SDimitry Andric
160b57cec5SDimitry Andricnamespace std
170b57cec5SDimitry Andric{
180b57cec5SDimitry Andric
190b57cec5SDimitry Andricstruct allocator_arg_t { };
200b57cec5SDimitry Andricinline constexpr allocator_arg_t allocator_arg = allocator_arg_t();
210b57cec5SDimitry Andric
220b57cec5SDimitry Andrictemplate <class T, class Alloc> struct uses_allocator;
230b57cec5SDimitry Andric
240b57cec5SDimitry Andrictemplate <class Ptr>
250b57cec5SDimitry Andricstruct pointer_traits
260b57cec5SDimitry Andric{
270b57cec5SDimitry Andric    typedef Ptr pointer;
280b57cec5SDimitry Andric    typedef <details> element_type;
290b57cec5SDimitry Andric    typedef <details> difference_type;
300b57cec5SDimitry Andric
310b57cec5SDimitry Andric    template <class U> using rebind = <details>;
320b57cec5SDimitry Andric
330b57cec5SDimitry Andric    static pointer pointer_to(<details>);
340b57cec5SDimitry Andric};
350b57cec5SDimitry Andric
360b57cec5SDimitry Andrictemplate <class T>
370b57cec5SDimitry Andricstruct pointer_traits<T*>
380b57cec5SDimitry Andric{
390b57cec5SDimitry Andric    typedef T* pointer;
400b57cec5SDimitry Andric    typedef T element_type;
410b57cec5SDimitry Andric    typedef ptrdiff_t difference_type;
420b57cec5SDimitry Andric
430b57cec5SDimitry Andric    template <class U> using rebind = U*;
440b57cec5SDimitry Andric
450b57cec5SDimitry Andric    static pointer pointer_to(<details>) noexcept; // constexpr in C++20
460b57cec5SDimitry Andric};
470b57cec5SDimitry Andric
480b57cec5SDimitry Andrictemplate <class T> constexpr T* to_address(T* p) noexcept; // C++20
49e8d8bef9SDimitry Andrictemplate <class Ptr> constexpr auto to_address(const Ptr& p) noexcept; // C++20
500b57cec5SDimitry Andric
510b57cec5SDimitry Andrictemplate <class Alloc>
520b57cec5SDimitry Andricstruct allocator_traits
530b57cec5SDimitry Andric{
540b57cec5SDimitry Andric    typedef Alloc                        allocator_type;
550b57cec5SDimitry Andric    typedef typename allocator_type::value_type
560b57cec5SDimitry Andric                                         value_type;
570b57cec5SDimitry Andric
580b57cec5SDimitry Andric    typedef Alloc::pointer | value_type* pointer;
590b57cec5SDimitry Andric    typedef Alloc::const_pointer
600b57cec5SDimitry Andric          | pointer_traits<pointer>::rebind<const value_type>
610b57cec5SDimitry Andric                                         const_pointer;
620b57cec5SDimitry Andric    typedef Alloc::void_pointer
630b57cec5SDimitry Andric          | pointer_traits<pointer>::rebind<void>
640b57cec5SDimitry Andric                                         void_pointer;
650b57cec5SDimitry Andric    typedef Alloc::const_void_pointer
660b57cec5SDimitry Andric          | pointer_traits<pointer>::rebind<const void>
670b57cec5SDimitry Andric                                         const_void_pointer;
680b57cec5SDimitry Andric    typedef Alloc::difference_type
690b57cec5SDimitry Andric          | pointer_traits<pointer>::difference_type
700b57cec5SDimitry Andric                                         difference_type;
710b57cec5SDimitry Andric    typedef Alloc::size_type
720b57cec5SDimitry Andric          | make_unsigned<difference_type>::type
730b57cec5SDimitry Andric                                         size_type;
740b57cec5SDimitry Andric    typedef Alloc::propagate_on_container_copy_assignment
750b57cec5SDimitry Andric          | false_type                   propagate_on_container_copy_assignment;
760b57cec5SDimitry Andric    typedef Alloc::propagate_on_container_move_assignment
770b57cec5SDimitry Andric          | false_type                   propagate_on_container_move_assignment;
780b57cec5SDimitry Andric    typedef Alloc::propagate_on_container_swap
790b57cec5SDimitry Andric          | false_type                   propagate_on_container_swap;
800b57cec5SDimitry Andric    typedef Alloc::is_always_equal
810b57cec5SDimitry Andric          | is_empty                     is_always_equal;
820b57cec5SDimitry Andric
835ffd83dbSDimitry Andric    template <class T> using rebind_alloc  = Alloc::rebind<T>::other | Alloc<T, Args...>;
840b57cec5SDimitry Andric    template <class T> using rebind_traits = allocator_traits<rebind_alloc<T>>;
850b57cec5SDimitry Andric
86e8d8bef9SDimitry Andric    static pointer allocate(allocator_type& a, size_type n);                          // constexpr and [[nodiscard]] in C++20
87e8d8bef9SDimitry Andric    static pointer allocate(allocator_type& a, size_type n, const_void_pointer hint); // constexpr and [[nodiscard]] in C++20
880b57cec5SDimitry Andric
89e8d8bef9SDimitry Andric    static void deallocate(allocator_type& a, pointer p, size_type n) noexcept; // constexpr in C++20
900b57cec5SDimitry Andric
910b57cec5SDimitry Andric    template <class T, class... Args>
92e8d8bef9SDimitry Andric    static void construct(allocator_type& a, T* p, Args&&... args); // constexpr in C++20
930b57cec5SDimitry Andric
940b57cec5SDimitry Andric    template <class T>
95e8d8bef9SDimitry Andric    static void destroy(allocator_type& a, T* p); // constexpr in C++20
960b57cec5SDimitry Andric
97e8d8bef9SDimitry Andric    static size_type max_size(const allocator_type& a); // noexcept in C++14, constexpr in C++20
98e8d8bef9SDimitry Andric    static allocator_type select_on_container_copy_construction(const allocator_type& a); // constexpr in C++20
990b57cec5SDimitry Andric};
1000b57cec5SDimitry Andric
10181ad6265SDimitry Andrictemplate<class Pointer>
10281ad6265SDimitry Andricstruct allocation_result {
10381ad6265SDimitry Andric    Pointer ptr;
10481ad6265SDimitry Andric    size_t count;
10581ad6265SDimitry Andric}; // since C++23
10681ad6265SDimitry Andric
10781ad6265SDimitry Andrictemplate<class Allocator>
10881ad6265SDimitry Andric[[nodiscard]] constexpr allocation_result<typename allocator_traits<Allocator>::pointer>
10981ad6265SDimitry Andric    allocate_at_least(Allocator& a, size_t n); // since C++23
11081ad6265SDimitry Andric
1110b57cec5SDimitry Andrictemplate <>
11223408297SDimitry Andricclass allocator<void> // removed in C++20
1130b57cec5SDimitry Andric{
1140b57cec5SDimitry Andricpublic:
115fe6060f1SDimitry Andric    typedef void*                                 pointer;
116fe6060f1SDimitry Andric    typedef const void*                           const_pointer;
117fe6060f1SDimitry Andric    typedef void                                  value_type;
1180b57cec5SDimitry Andric
119fe6060f1SDimitry Andric    template <class _Up> struct rebind {typedef allocator<_Up> other;};
1200b57cec5SDimitry Andric};
1210b57cec5SDimitry Andric
1220b57cec5SDimitry Andrictemplate <class T>
1230b57cec5SDimitry Andricclass allocator
1240b57cec5SDimitry Andric{
1250b57cec5SDimitry Andricpublic:
126e8d8bef9SDimitry Andric    typedef size_t    size_type;
127e8d8bef9SDimitry Andric    typedef ptrdiff_t difference_type;
1285ffd83dbSDimitry Andric    typedef T*        pointer;                           // deprecated in C++17, removed in C++20
1295ffd83dbSDimitry Andric    typedef const T*  const_pointer;                     // deprecated in C++17, removed in C++20
1305ffd83dbSDimitry Andric    typedef typename add_lvalue_reference<T>::type
1315ffd83dbSDimitry Andric                      reference;                         // deprecated in C++17, removed in C++20
1325ffd83dbSDimitry Andric    typedef typename add_lvalue_reference<const T>::type
1335ffd83dbSDimitry Andric                      const_reference;                   // deprecated in C++17, removed in C++20
1345ffd83dbSDimitry Andric
1350b57cec5SDimitry Andric    typedef T         value_type;
1360b57cec5SDimitry Andric
1375ffd83dbSDimitry Andric    template <class U> struct rebind {typedef allocator<U> other;}; // deprecated in C++17, removed in C++20
1385ffd83dbSDimitry Andric
1395ffd83dbSDimitry Andric    typedef true_type propagate_on_container_move_assignment;
1405ffd83dbSDimitry Andric    typedef true_type is_always_equal;
1410b57cec5SDimitry Andric
1420b57cec5SDimitry Andric    constexpr allocator() noexcept;                      // constexpr in C++20
1430b57cec5SDimitry Andric    constexpr allocator(const allocator&) noexcept;      // constexpr in C++20
1440b57cec5SDimitry Andric    template <class U>
1450b57cec5SDimitry Andric      constexpr allocator(const allocator<U>&) noexcept; // constexpr in C++20
146e8d8bef9SDimitry Andric    ~allocator();                                        // constexpr in C++20
1475ffd83dbSDimitry Andric    pointer address(reference x) const noexcept;             // deprecated in C++17, removed in C++20
1485ffd83dbSDimitry Andric    const_pointer address(const_reference x) const noexcept; // deprecated in C++17, removed in C++20
1495ffd83dbSDimitry Andric    T* allocate(size_t n, const void* hint);          // deprecated in C++17, removed in C++20
150e8d8bef9SDimitry Andric    T* allocate(size_t n);                              // constexpr in C++20
151e8d8bef9SDimitry Andric    void deallocate(T* p, size_t n) noexcept;           // constexpr in C++20
1525ffd83dbSDimitry Andric    size_type max_size() const noexcept;              // deprecated in C++17, removed in C++20
1530b57cec5SDimitry Andric    template<class U, class... Args>
1545ffd83dbSDimitry Andric        void construct(U* p, Args&&... args);         // deprecated in C++17, removed in C++20
1550b57cec5SDimitry Andric    template <class U>
1565ffd83dbSDimitry Andric        void destroy(U* p);                           // deprecated in C++17, removed in C++20
1570b57cec5SDimitry Andric};
1580b57cec5SDimitry Andric
1590b57cec5SDimitry Andrictemplate <class T, class U>
160e8d8bef9SDimitry Andricbool operator==(const allocator<T>&, const allocator<U>&) noexcept; // constexpr in C++20
1610b57cec5SDimitry Andric
1620b57cec5SDimitry Andrictemplate <class T, class U>
163e8d8bef9SDimitry Andricbool operator!=(const allocator<T>&, const allocator<U>&) noexcept; // constexpr in C++20
1640b57cec5SDimitry Andric
1650b57cec5SDimitry Andrictemplate <class OutputIterator, class T>
166fe6060f1SDimitry Andricclass raw_storage_iterator // deprecated in C++17, removed in C++20
167fe6060f1SDimitry Andric    : public iterator<output_iterator_tag, void, void, void, void> // until C++17
1680b57cec5SDimitry Andric{
1690b57cec5SDimitry Andricpublic:
170fe6060f1SDimitry Andric    typedef output_iterator_tag iterator_category;
171fe6060f1SDimitry Andric    typedef void                value_type;
172fe6060f1SDimitry Andric    typedef void                difference_type; // until C++20
173fe6060f1SDimitry Andric    typedef ptrdiff_t           difference_type; // since C++20
174fe6060f1SDimitry Andric    typedef void                pointer;
175fe6060f1SDimitry Andric    typedef void                reference;
176fe6060f1SDimitry Andric
1770b57cec5SDimitry Andric    explicit raw_storage_iterator(OutputIterator x);
1780b57cec5SDimitry Andric    raw_storage_iterator& operator*();
1790b57cec5SDimitry Andric    raw_storage_iterator& operator=(const T& element);
1800b57cec5SDimitry Andric    raw_storage_iterator& operator++();
1810b57cec5SDimitry Andric    raw_storage_iterator  operator++(int);
1820b57cec5SDimitry Andric};
1830b57cec5SDimitry Andric
1840b57cec5SDimitry Andrictemplate <class T> pair<T*,ptrdiff_t> get_temporary_buffer(ptrdiff_t n) noexcept;
1850b57cec5SDimitry Andrictemplate <class T> void               return_temporary_buffer(T* p) noexcept;
1860b57cec5SDimitry Andric
1870b57cec5SDimitry Andrictemplate <class T> T* addressof(T& r) noexcept;
1880b57cec5SDimitry Andrictemplate <class T> T* addressof(const T&& r) noexcept = delete;
1890b57cec5SDimitry Andric
1900b57cec5SDimitry Andrictemplate <class InputIterator, class ForwardIterator>
1910b57cec5SDimitry AndricForwardIterator
1920b57cec5SDimitry Andricuninitialized_copy(InputIterator first, InputIterator last, ForwardIterator result);
1930b57cec5SDimitry Andric
19404eeddc0SDimitry Andricnamespace ranges {
19504eeddc0SDimitry Andric
19604eeddc0SDimitry Andrictemplate<class InputIterator, class OutputIterator>
19704eeddc0SDimitry Andricusing uninitialized_copy_result = in_out_result<InputIterator, OutputIterator>; // since C++20
19804eeddc0SDimitry Andric
19904eeddc0SDimitry Andrictemplate<input_iterator InputIterator, sentinel-for<InputIterator> Sentinel1, nothrow-forward-iterator OutputIterator, nothrow-sentinel-for<OutputIterator> Sentinel2>
20004eeddc0SDimitry Andric  requires constructible_from<iter_value_t<OutputIterator>, iter_reference_t<InputIterator>>
20104eeddc0SDimitry Andricuninitialized_copy_result<InputIterator, OutputIterator>
20204eeddc0SDimitry Andricuninitialized_copy(InputIterator ifirst, Sentinel1 ilast, OutputIterator ofirst, Sentinel2 olast); // since C++20
20304eeddc0SDimitry Andric
20404eeddc0SDimitry Andrictemplate<input_range InputRange, nothrow-forward-range OutputRange>
20504eeddc0SDimitry Andric  requires constructible_from<range_value_t<OutputRange>, range_reference_t<InputRange>>
20604eeddc0SDimitry Andricuninitialized_copy_result<borrowed_iterator_t<InputRange>, borrowed_iterator_t<OutputRange>>
20704eeddc0SDimitry Andricuninitialized_copy(InputRange&& in_range, OutputRange&& out_range); // since C++20
20804eeddc0SDimitry Andric
20904eeddc0SDimitry Andric}
21004eeddc0SDimitry Andric
2110b57cec5SDimitry Andrictemplate <class InputIterator, class Size, class ForwardIterator>
2120b57cec5SDimitry AndricForwardIterator
2130b57cec5SDimitry Andricuninitialized_copy_n(InputIterator first, Size n, ForwardIterator result);
2140b57cec5SDimitry Andric
21504eeddc0SDimitry Andricnamespace ranges {
21604eeddc0SDimitry Andric
21704eeddc0SDimitry Andrictemplate<class InputIterator, class OutputIterator>
21804eeddc0SDimitry Andricusing uninitialized_copy_n_result = in_out_result<InputIterator, OutputIterator>; // since C++20
21904eeddc0SDimitry Andric
22004eeddc0SDimitry Andrictemplate<input_iterator InputIterator, nothrow-forward-iterator OutputIterator, nothrow-sentinel-for<OutputIterator> Sentinel>
22104eeddc0SDimitry Andric  requires constructible_from<iter_value_t<OutputIterator>, iter_reference_t<InputIterator>>
22204eeddc0SDimitry Andricuninitialized_copy_n_result<InputIterator, OutputIterator>
22304eeddc0SDimitry Andricuninitialized_copy_n(InputIterator ifirst, iter_difference_t<InputIterator> n, OutputIterator ofirst, Sentinel olast); // since C++20
22404eeddc0SDimitry Andric
22504eeddc0SDimitry Andric}
22604eeddc0SDimitry Andric
2270b57cec5SDimitry Andrictemplate <class ForwardIterator, class T>
2280b57cec5SDimitry Andricvoid uninitialized_fill(ForwardIterator first, ForwardIterator last, const T& x);
2290b57cec5SDimitry Andric
23004eeddc0SDimitry Andricnamespace ranges {
23104eeddc0SDimitry Andric
2320eae32dcSDimitry Andrictemplate <nothrow-forward-iterator ForwardIterator, nothrow-sentinel-for<ForwardIterator> Sentinel, class T>
2330eae32dcSDimitry Andric  requires constructible_from<iter_value_t<ForwardIterator>, const T&>
23404eeddc0SDimitry AndricForwardIterator uninitialized_fill(ForwardIterator first, Sentinel last, const T& x); // since C++20
2350eae32dcSDimitry Andric
2360eae32dcSDimitry Andrictemplate <nothrow-forward-range ForwardRange, class T>
2370eae32dcSDimitry Andric  requires constructible_from<range_value_t<ForwardRange>, const T&>
23804eeddc0SDimitry Andricborrowed_iterator_t<ForwardRange> uninitialized_fill(ForwardRange&& range, const T& x); // since C++20
23904eeddc0SDimitry Andric
24004eeddc0SDimitry Andric}
2410eae32dcSDimitry Andric
2420b57cec5SDimitry Andrictemplate <class ForwardIterator, class Size, class T>
2430b57cec5SDimitry AndricForwardIterator
2440b57cec5SDimitry Andricuninitialized_fill_n(ForwardIterator first, Size n, const T& x);
2450b57cec5SDimitry Andric
24604eeddc0SDimitry Andricnamespace ranges {
24704eeddc0SDimitry Andric
2480eae32dcSDimitry Andrictemplate <nothrow-forward-iterator ForwardIterator, class T>
2490eae32dcSDimitry Andric  requires constructible_from<iter_value_t<ForwardIterator>, const T&>
25004eeddc0SDimitry AndricForwardIterator uninitialized_fill_n(ForwardIterator first, iter_difference_t<ForwardIterator> n); // since C++20
25104eeddc0SDimitry Andric
25204eeddc0SDimitry Andric}
2530eae32dcSDimitry Andric
254e8d8bef9SDimitry Andrictemplate <class T, class ...Args>
255e8d8bef9SDimitry Andricconstexpr T* construct_at(T* location, Args&& ...args); // since C++20
256e8d8bef9SDimitry Andric
25704eeddc0SDimitry Andricnamespace ranges {
25804eeddc0SDimitry Andric  template<class T, class... Args>
25904eeddc0SDimitry Andric    constexpr T* construct_at(T* location, Args&&... args); // since C++20
26004eeddc0SDimitry Andric}
26104eeddc0SDimitry Andric
2620b57cec5SDimitry Andrictemplate <class T>
263e8d8bef9SDimitry Andricvoid destroy_at(T* location); // constexpr in C++20
2640b57cec5SDimitry Andric
26504eeddc0SDimitry Andricnamespace ranges {
26604eeddc0SDimitry Andric  template<destructible T>
26704eeddc0SDimitry Andric    constexpr void destroy_at(T* location) noexcept; // since C++20
26804eeddc0SDimitry Andric}
26904eeddc0SDimitry Andric
2700b57cec5SDimitry Andrictemplate <class ForwardIterator>
271e8d8bef9SDimitry Andricvoid destroy(ForwardIterator first, ForwardIterator last); // constexpr in C++20
2720b57cec5SDimitry Andric
27304eeddc0SDimitry Andricnamespace ranges {
27404eeddc0SDimitry Andric  template<nothrow-input-iterator InputIterator, nothrow-sentinel-for<InputIterator> Sentinel>
27504eeddc0SDimitry Andric    requires destructible<iter_value_t<InputIterator>>
27604eeddc0SDimitry Andric    constexpr InputIterator destroy(InputIterator first, Sentinel last) noexcept; // since C++20
27704eeddc0SDimitry Andric  template<nothrow-input-range InputRange>
27804eeddc0SDimitry Andric    requires destructible<range_value_t<InputRange>>
27904eeddc0SDimitry Andric    constexpr borrowed_iterator_t<InputRange> destroy(InputRange&& range) noexcept; // since C++20
28004eeddc0SDimitry Andric}
28104eeddc0SDimitry Andric
2820b57cec5SDimitry Andrictemplate <class ForwardIterator, class Size>
283e8d8bef9SDimitry AndricForwardIterator destroy_n(ForwardIterator first, Size n); // constexpr in C++20
2840b57cec5SDimitry Andric
28504eeddc0SDimitry Andricnamespace ranges {
28604eeddc0SDimitry Andric  template<nothrow-input-iterator InputIterator>
28704eeddc0SDimitry Andric    requires destructible<iter_value_t<InputIterator>>
28804eeddc0SDimitry Andric    constexpr InputIterator destroy_n(InputIterator first, iter_difference_t<InputIterator> n) noexcept; // since C++20
28904eeddc0SDimitry Andric}
29004eeddc0SDimitry Andric
2910b57cec5SDimitry Andrictemplate <class InputIterator, class ForwardIterator>
2920b57cec5SDimitry Andric ForwardIterator uninitialized_move(InputIterator first, InputIterator last, ForwardIterator result);
2930b57cec5SDimitry Andric
29404eeddc0SDimitry Andricnamespace ranges {
29504eeddc0SDimitry Andric
29604eeddc0SDimitry Andrictemplate<class InputIterator, class OutputIterator>
29704eeddc0SDimitry Andricusing uninitialized_move_result = in_out_result<InputIterator, OutputIterator>; // since C++20
29804eeddc0SDimitry Andric
29904eeddc0SDimitry Andrictemplate <input_iterator InputIterator, sentinel_for<InputIterator> Sentinel1, nothrow-forward-iterator OutputIterator, nothrow-sentinel-for<O> Sentinel2>
30004eeddc0SDimitry Andric  requires constructible_from<iter_value_t<OutputIterator>, iter_rvalue_reference_t<InputIterator>>
30104eeddc0SDimitry Andricuninitialized_move_result<InputIterator, OutputIterator>
30204eeddc0SDimitry Andricuninitialized_move(InputIterator ifirst, Sentinel1 ilast, OutputIterator ofirst, Sentinel2 olast); // since C++20
30304eeddc0SDimitry Andric
30404eeddc0SDimitry Andrictemplate<input_range InputRange, nothrow-forward-range OutputRange>
30504eeddc0SDimitry Andric  requires constructible_from<range_value_t<OutputRange>, range_rvalue_reference_t<InputRange>>
30604eeddc0SDimitry Andricuninitialized_move_result<borrowed_iterator_t<InputRange>, borrowed_iterator_t<OutputRange>>
30704eeddc0SDimitry Andricuninitialized_move(InputRange&& in_range, OutputRange&& out_range); // since C++20
30804eeddc0SDimitry Andric
30904eeddc0SDimitry Andric}
31004eeddc0SDimitry Andric
3110b57cec5SDimitry Andrictemplate <class InputIterator, class Size, class ForwardIterator>
3120b57cec5SDimitry Andric pair<InputIterator,ForwardIterator> uninitialized_move_n(InputIterator first, Size n, ForwardIterator result);
3130b57cec5SDimitry Andric
31404eeddc0SDimitry Andricnamespace ranges {
31504eeddc0SDimitry Andric
31604eeddc0SDimitry Andrictemplate<class InputIterator, class OutputIterator>
31704eeddc0SDimitry Andricusing uninitialized_move_n_result = in_out_result<InputIterator, OutputIterator>; // since C++20
31804eeddc0SDimitry Andric
31904eeddc0SDimitry Andrictemplate<input_iterator InputIterator, nothrow-forward-iterator OutputIterator, nothrow-sentinel-for<OutputIterator> Sentinel>
32004eeddc0SDimitry Andric  requires constructible_from<iter_value_t<OutputIterator>, iter_rvalue_reference_t<InputIterator>>
32104eeddc0SDimitry Andricuninitialized_move_n_result<InputIterator, OutputIterator>
32204eeddc0SDimitry Andricuninitialized_move_n(InputIterator ifirst, iter_difference_t<InputIterator> n, OutputIterator ofirst, Sentinel olast); // since C++20
32304eeddc0SDimitry Andric
32404eeddc0SDimitry Andric}
32504eeddc0SDimitry Andric
3260b57cec5SDimitry Andrictemplate <class ForwardIterator>
3270b57cec5SDimitry Andric void uninitialized_value_construct(ForwardIterator first, ForwardIterator last);
3280b57cec5SDimitry Andric
32904eeddc0SDimitry Andricnamespace ranges {
33004eeddc0SDimitry Andric
3310eae32dcSDimitry Andrictemplate <nothrow-forward-iterator ForwardIterator, nothrow-sentinel-for<ForwardIterator> Sentinel>
3320eae32dcSDimitry Andric  requires default_initializable<iter_value_t<ForwardIterator>>
33304eeddc0SDimitry Andric ForwardIterator uninitialized_value_construct(ForwardIterator first, Sentinel last); // since C++20
3340eae32dcSDimitry Andric
3350eae32dcSDimitry Andrictemplate <nothrow-forward-range ForwardRange>
3360eae32dcSDimitry Andric  requires default_initializable<range_value_t<ForwardRange>>
33704eeddc0SDimitry Andric borrowed_iterator_t<ForwardRange> uninitialized_value_construct(ForwardRange&& r); // since C++20
33804eeddc0SDimitry Andric
33904eeddc0SDimitry Andric}
3400eae32dcSDimitry Andric
3410b57cec5SDimitry Andrictemplate <class ForwardIterator, class Size>
3420b57cec5SDimitry Andric ForwardIterator uninitialized_value_construct_n(ForwardIterator first, Size n);
3430b57cec5SDimitry Andric
34404eeddc0SDimitry Andricnamespace ranges {
34504eeddc0SDimitry Andric
3460eae32dcSDimitry Andrictemplate <nothrow-forward-iterator ForwardIterator>
3470eae32dcSDimitry Andric  requires default_initializable<iter_value_t<ForwardIterator>>
34804eeddc0SDimitry Andric ForwardIterator uninitialized_value_construct_n(ForwardIterator first, iter_difference_t<ForwardIterator> n); // since C++20
34904eeddc0SDimitry Andric
35004eeddc0SDimitry Andric}
3510eae32dcSDimitry Andric
3520b57cec5SDimitry Andrictemplate <class ForwardIterator>
3530b57cec5SDimitry Andric void uninitialized_default_construct(ForwardIterator first, ForwardIterator last);
3540b57cec5SDimitry Andric
35504eeddc0SDimitry Andricnamespace ranges {
35604eeddc0SDimitry Andric
3570eae32dcSDimitry Andrictemplate <nothrow-forward-iterator ForwardIterator, nothrow-sentinel-for<ForwardIterator> Sentinel>
3580eae32dcSDimitry Andric  requires default_initializable<iter_value_t<ForwardIterator>>
35904eeddc0SDimitry Andric ForwardIterator uninitialized_default_construct(ForwardIterator first, Sentinel last); // since C++20
3600eae32dcSDimitry Andric
3610eae32dcSDimitry Andrictemplate <nothrow-forward-range ForwardRange>
3620eae32dcSDimitry Andric  requires default_initializable<range_value_t<ForwardRange>>
36304eeddc0SDimitry Andric borrowed_iterator_t<ForwardRange> uninitialized_default_construct(ForwardRange&& r); // since C++20
36404eeddc0SDimitry Andric
36504eeddc0SDimitry Andric}
3660eae32dcSDimitry Andric
3670b57cec5SDimitry Andrictemplate <class ForwardIterator, class Size>
3680b57cec5SDimitry Andric ForwardIterator uninitialized_default_construct_n(ForwardIterator first, Size n);
3690b57cec5SDimitry Andric
37004eeddc0SDimitry Andricnamespace ranges {
37104eeddc0SDimitry Andric
3720eae32dcSDimitry Andrictemplate <nothrow-forward-iterator ForwardIterator>
3730eae32dcSDimitry Andric  requires default_initializable<iter_value_t<ForwardIterator>>
37404eeddc0SDimitry Andric ForwardIterator uninitialized_default_construct_n(ForwardIterator first, iter_difference_t<ForwardIterator> n); // since C++20
37504eeddc0SDimitry Andric
37604eeddc0SDimitry Andric}
3770eae32dcSDimitry Andric
3780b57cec5SDimitry Andrictemplate <class Y> struct auto_ptr_ref {};      // deprecated in C++11, removed in C++17
3790b57cec5SDimitry Andric
3800b57cec5SDimitry Andrictemplate<class X>
3810b57cec5SDimitry Andricclass auto_ptr                                  // deprecated in C++11, removed in C++17
3820b57cec5SDimitry Andric{
3830b57cec5SDimitry Andricpublic:
3840b57cec5SDimitry Andric    typedef X element_type;
3850b57cec5SDimitry Andric
3860b57cec5SDimitry Andric    explicit auto_ptr(X* p =0) throw();
3870b57cec5SDimitry Andric    auto_ptr(auto_ptr&) throw();
3880b57cec5SDimitry Andric    template<class Y> auto_ptr(auto_ptr<Y>&) throw();
3890b57cec5SDimitry Andric    auto_ptr& operator=(auto_ptr&) throw();
3900b57cec5SDimitry Andric    template<class Y> auto_ptr& operator=(auto_ptr<Y>&) throw();
3910b57cec5SDimitry Andric    auto_ptr& operator=(auto_ptr_ref<X> r) throw();
3920b57cec5SDimitry Andric    ~auto_ptr() throw();
3930b57cec5SDimitry Andric
3940b57cec5SDimitry Andric    typename add_lvalue_reference<X>::type operator*() const throw();
3950b57cec5SDimitry Andric    X* operator->() const throw();
3960b57cec5SDimitry Andric    X* get() const throw();
3970b57cec5SDimitry Andric    X* release() throw();
3980b57cec5SDimitry Andric    void reset(X* p =0) throw();
3990b57cec5SDimitry Andric
4000b57cec5SDimitry Andric    auto_ptr(auto_ptr_ref<X>) throw();
4010b57cec5SDimitry Andric    template<class Y> operator auto_ptr_ref<Y>() throw();
4020b57cec5SDimitry Andric    template<class Y> operator auto_ptr<Y>() throw();
4030b57cec5SDimitry Andric};
4040b57cec5SDimitry Andric
4050b57cec5SDimitry Andrictemplate <class T>
4060b57cec5SDimitry Andricstruct default_delete
4070b57cec5SDimitry Andric{
4080b57cec5SDimitry Andric    constexpr default_delete() noexcept = default;
409*bdd1243dSDimitry Andric    template <class U> constexpr default_delete(const default_delete<U>&) noexcept; // constexpr since C++23
4100b57cec5SDimitry Andric
411*bdd1243dSDimitry Andric    constexpr void operator()(T*) const noexcept;                                   // constexpr since C++23
4120b57cec5SDimitry Andric};
4130b57cec5SDimitry Andric
4140b57cec5SDimitry Andrictemplate <class T>
4150b57cec5SDimitry Andricstruct default_delete<T[]>
4160b57cec5SDimitry Andric{
4170b57cec5SDimitry Andric    constexpr default_delete() noexcept = default;
418*bdd1243dSDimitry Andric    template <class U> constexpr default_delete(const default_delete <U[]>&) noexcept; // constexpr since C++23
419*bdd1243dSDimitry Andric    constexpr void operator()(T*) const noexcept;                                      // constexpr since C++23
4200b57cec5SDimitry Andric    template <class U> void operator()(U*) const = delete;
4210b57cec5SDimitry Andric};
4220b57cec5SDimitry Andric
4230b57cec5SDimitry Andrictemplate <class T, class D = default_delete<T>>
4240b57cec5SDimitry Andricclass unique_ptr
4250b57cec5SDimitry Andric{
4260b57cec5SDimitry Andricpublic:
4270b57cec5SDimitry Andric    typedef see below pointer;
4280b57cec5SDimitry Andric    typedef T element_type;
4290b57cec5SDimitry Andric    typedef D deleter_type;
4300b57cec5SDimitry Andric
4310b57cec5SDimitry Andric    // constructors
4320b57cec5SDimitry Andric    constexpr unique_ptr() noexcept;
433*bdd1243dSDimitry Andric    constexpr explicit unique_ptr(pointer p) noexcept;           // constexpr since C++23
434*bdd1243dSDimitry Andric    constexpr unique_ptr(pointer p, see below d1) noexcept;      // constexpr since C++23
435*bdd1243dSDimitry Andric    constexpr unique_ptr(pointer p, see below d2) noexcept;      // constexpr since C++23
436*bdd1243dSDimitry Andric    constexpr unique_ptr(unique_ptr&& u) noexcept;               // constexpr since C++23
437*bdd1243dSDimitry Andric    constexpr unique_ptr(nullptr_t) noexcept : unique_ptr() { }
4380b57cec5SDimitry Andric    template <class U, class E>
439*bdd1243dSDimitry Andric        constexpr unique_ptr(unique_ptr<U, E>&& u) noexcept;     // constexpr since C++23
4400b57cec5SDimitry Andric    template <class U>
4410b57cec5SDimitry Andric        unique_ptr(auto_ptr<U>&& u) noexcept;                    // removed in C++17
4420b57cec5SDimitry Andric
4430b57cec5SDimitry Andric    // destructor
444*bdd1243dSDimitry Andric    constexpr ~unique_ptr();                                     // constexpr since C++23
4450b57cec5SDimitry Andric
4460b57cec5SDimitry Andric    // assignment
447*bdd1243dSDimitry Andric    constexpr unique_ptr& operator=(unique_ptr&& u) noexcept;                         // constexpr since C++23
448*bdd1243dSDimitry Andric    template <class U, class E>
449*bdd1243dSDimitry Andric    constexpr unique_ptr& operator=(unique_ptr<U, E>&& u) noexcept;                   // constexpr since C++23
450*bdd1243dSDimitry Andric    constexpr unique_ptr& operator=(nullptr_t) noexcept;                              // constexpr since C++23
4510b57cec5SDimitry Andric
4520b57cec5SDimitry Andric    // observers
453*bdd1243dSDimitry Andric    typename constexpr add_lvalue_reference<T>::type operator*() const;               // constexpr since C++23
454*bdd1243dSDimitry Andric    constexpr pointer operator->() const noexcept;                                    // constexpr since C++23
455*bdd1243dSDimitry Andric    constexpr pointer get() const noexcept;                                           // constexpr since C++23
456*bdd1243dSDimitry Andric    constexpr deleter_type& get_deleter() noexcept;                                   // constexpr since C++23
457*bdd1243dSDimitry Andric    constexpr const deleter_type& get_deleter() const noexcept;                       // constexpr since C++23
458*bdd1243dSDimitry Andric    constexpr explicit operator bool() const noexcept;                                // constexpr since C++23
4590b57cec5SDimitry Andric
4600b57cec5SDimitry Andric    // modifiers
461*bdd1243dSDimitry Andric    constexpr pointer release() noexcept;                                             // constexpr since C++23
462*bdd1243dSDimitry Andric    constexpr void reset(pointer p = pointer()) noexcept;                             // constexpr since C++23
463*bdd1243dSDimitry Andric    constexpr void swap(unique_ptr& u) noexcept;                                      // constexpr since C++23
4640b57cec5SDimitry Andric};
4650b57cec5SDimitry Andric
4660b57cec5SDimitry Andrictemplate <class T, class D>
4670b57cec5SDimitry Andricclass unique_ptr<T[], D>
4680b57cec5SDimitry Andric{
4690b57cec5SDimitry Andricpublic:
4700b57cec5SDimitry Andric    typedef implementation-defined pointer;
4710b57cec5SDimitry Andric    typedef T element_type;
4720b57cec5SDimitry Andric    typedef D deleter_type;
4730b57cec5SDimitry Andric
4740b57cec5SDimitry Andric    // constructors
4750b57cec5SDimitry Andric    constexpr unique_ptr() noexcept;
476*bdd1243dSDimitry Andric    constexpr explicit unique_ptr(pointer p) noexcept;          // constexpr since C++23
477*bdd1243dSDimitry Andric    constexpr unique_ptr(pointer p, see below d) noexcept;      // constexpr since C++23
478*bdd1243dSDimitry Andric    constexpr unique_ptr(pointer p, see below d) noexcept;      // constexpr since C++23
479*bdd1243dSDimitry Andric    constexpr unique_ptr(unique_ptr&& u) noexcept;              // constexpr since C++23
480*bdd1243dSDimitry Andric    template <class U, class E>
481*bdd1243dSDimitry Andric    constexpr unique_ptr(unique_ptr <U, E>&& u) noexcept;       // constexpr since C++23
482*bdd1243dSDimitry Andric    constexpr unique_ptr(nullptr_t) noexcept : unique_ptr() { }
4830b57cec5SDimitry Andric
4840b57cec5SDimitry Andric    // destructor
485*bdd1243dSDimitry Andric    constexpr ~unique_ptr();                                    // constexpr since C++23
4860b57cec5SDimitry Andric
4870b57cec5SDimitry Andric    // assignment
488*bdd1243dSDimitry Andric    constexpr unique_ptr& operator=(unique_ptr&& u) noexcept;        // constexpr since C++23
489*bdd1243dSDimitry Andric    template <class U, class E>
490*bdd1243dSDimitry Andric    constexpr unique_ptr& operator=(unique_ptr <U, E>&& u) noexcept; // constexpr since C++23
491*bdd1243dSDimitry Andric    constexpr unique_ptr& operator=(nullptr_t) noexcept;             // constexpr since C++23
4920b57cec5SDimitry Andric
4930b57cec5SDimitry Andric    // observers
494*bdd1243dSDimitry Andric    constexpr T& operator[](size_t i) const;                    // constexpr since C++23
495*bdd1243dSDimitry Andric    constexpr pointer get() const noexcept;                     // constexpr since C++23
496*bdd1243dSDimitry Andric    constexpr deleter_type& get_deleter() noexcept;             // constexpr since C++23
497*bdd1243dSDimitry Andric    constexpr const deleter_type& get_deleter() const noexcept; // constexpr since C++23
498*bdd1243dSDimitry Andric    constexpr explicit operator bool() const noexcept;          // constexpr since C++23
4990b57cec5SDimitry Andric
5000b57cec5SDimitry Andric    // modifiers
501*bdd1243dSDimitry Andric    constexpr pointer release() noexcept;                       // constexpr since C++23
502*bdd1243dSDimitry Andric    constexpr void reset(pointer p = pointer()) noexcept;       // constexpr since C++23
503*bdd1243dSDimitry Andric    constexpr void reset(nullptr_t) noexcept;                   // constexpr since C++23
5040b57cec5SDimitry Andric  template <class U> void reset(U) = delete;
505*bdd1243dSDimitry Andric    constexpr void swap(unique_ptr& u) noexcept;                // constexpr since C++23
5060b57cec5SDimitry Andric};
5070b57cec5SDimitry Andric
5080b57cec5SDimitry Andrictemplate <class T, class D>
509*bdd1243dSDimitry Andric    constexpr void swap(unique_ptr<T, D>& x, unique_ptr<T, D>& y) noexcept;                 // constexpr since C++23
5100b57cec5SDimitry Andric
5110b57cec5SDimitry Andrictemplate <class T1, class D1, class T2, class D2>
512*bdd1243dSDimitry Andric    constexpr bool operator==(const unique_ptr<T1, D1>& x, const unique_ptr<T2, D2>& y);    // constexpr since C++23
5130b57cec5SDimitry Andrictemplate <class T1, class D1, class T2, class D2>
514*bdd1243dSDimitry Andric    bool operator!=(const unique_ptr<T1, D1>& x, const unique_ptr<T2, D2>& y);              // removed in C++20
5150b57cec5SDimitry Andrictemplate <class T1, class D1, class T2, class D2>
5160b57cec5SDimitry Andric    bool operator<(const unique_ptr<T1, D1>& x, const unique_ptr<T2, D2>& y);
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);
523*bdd1243dSDimitry Andrictemplate<class T1, class D1, class T2, class D2>
524*bdd1243dSDimitry Andric  requires three_way_comparable_with<typename unique_ptr<T1, D1>::pointer,
525*bdd1243dSDimitry Andric                                     typename unique_ptr<T2, D2>::pointer>
526*bdd1243dSDimitry Andric  compare_three_way_result_t<typename unique_ptr<T1, D1>::pointer,
527*bdd1243dSDimitry Andric                             typename unique_ptr<T2, D2>::pointer>
528*bdd1243dSDimitry Andric    operator<=>(const unique_ptr<T1, D1>& x, const unique_ptr<T2, D2>& y);      // C++20
5290b57cec5SDimitry Andric
5300b57cec5SDimitry Andrictemplate <class T, class D>
531*bdd1243dSDimitry Andric    constexpr bool operator==(const unique_ptr<T, D>& x, nullptr_t) noexcept;   // constexpr since C++23
5320b57cec5SDimitry Andrictemplate <class T, class D>
533*bdd1243dSDimitry Andric    bool operator==(nullptr_t, const unique_ptr<T, D>& y) noexcept;             // removed in C++20
5340b57cec5SDimitry Andrictemplate <class T, class D>
535*bdd1243dSDimitry Andric    bool operator!=(const unique_ptr<T, D>& x, nullptr_t) noexcept;             // removed in C++20
5360b57cec5SDimitry Andrictemplate <class T, class D>
537*bdd1243dSDimitry Andric    bool operator!=(nullptr_t, const unique_ptr<T, D>& y) noexcept;             // removed in C++20
5380b57cec5SDimitry Andric
5390b57cec5SDimitry Andrictemplate <class T, class D>
540*bdd1243dSDimitry Andric    constexpr bool operator<(const unique_ptr<T, D>& x, nullptr_t);     // constexpr since C++23
5410b57cec5SDimitry Andrictemplate <class T, class D>
542*bdd1243dSDimitry Andric    constexpr bool operator<(nullptr_t, const unique_ptr<T, D>& y);     // constexpr since C++23
5430b57cec5SDimitry Andrictemplate <class T, class D>
544*bdd1243dSDimitry Andric    constexpr bool operator<=(const unique_ptr<T, D>& x, nullptr_t);    // constexpr since C++23
5450b57cec5SDimitry Andrictemplate <class T, class D>
546*bdd1243dSDimitry Andric    constexpr bool operator<=(nullptr_t, const unique_ptr<T, D>& y);    // constexpr since C++23
5470b57cec5SDimitry Andrictemplate <class T, class D>
548*bdd1243dSDimitry Andric    constexpr bool operator>(const unique_ptr<T, D>& x, nullptr_t);     // constexpr since C++23
5490b57cec5SDimitry Andrictemplate <class T, class D>
550*bdd1243dSDimitry Andric    constexpr bool operator>(nullptr_t, const unique_ptr<T, D>& y);     // constexpr since C++23
5510b57cec5SDimitry Andrictemplate <class T, class D>
552*bdd1243dSDimitry Andric    constexpr bool operator>=(const unique_ptr<T, D>& x, nullptr_t);    // constexpr since C++23
5530b57cec5SDimitry Andrictemplate <class T, class D>
554*bdd1243dSDimitry Andric    constexpr bool operator>=(nullptr_t, const unique_ptr<T, D>& y);    // constexpr since C++23
555*bdd1243dSDimitry Andrictemplate<class T, class D>
556*bdd1243dSDimitry Andric  requires three_way_comparable<typename unique_ptr<T, D>::pointer>
557*bdd1243dSDimitry Andric  compare_three_way_result_t<typename unique_ptr<T, D>::pointer>
558*bdd1243dSDimitry Andric    constexpr operator<=>(const unique_ptr<T, D>& x, nullptr_t);        // C++20, constexpr since C++23
5590b57cec5SDimitry Andric
5600b57cec5SDimitry Andricclass bad_weak_ptr
5610b57cec5SDimitry Andric    : public std::exception
5620b57cec5SDimitry Andric{
5630b57cec5SDimitry Andric    bad_weak_ptr() noexcept;
5640b57cec5SDimitry Andric};
5650b57cec5SDimitry Andric
566*bdd1243dSDimitry Andrictemplate<class T, class... Args>
567*bdd1243dSDimitry Andricconstexpr unique_ptr<T> make_unique(Args&&... args);                            // C++14, constexpr since C++23
568*bdd1243dSDimitry Andrictemplate<class T>
569*bdd1243dSDimitry Andricconstexpr unique_ptr<T> make_unique(size_t n);                                  // C++14, constexpr since C++23
5700b57cec5SDimitry Andrictemplate<class T, class... Args> unspecified   make_unique(Args&&...) = delete; // C++14, T == U[N]
5710b57cec5SDimitry Andric
572*bdd1243dSDimitry Andrictemplate<class T>
573*bdd1243dSDimitry Andric  constexpr unique_ptr<T> make_unique_for_overwrite();                        // T is not array, C++20, constexpr since C++23
574*bdd1243dSDimitry Andrictemplate<class T>
575*bdd1243dSDimitry Andric  constexpr unique_ptr<T> make_unique_for_overwrite(size_t n);                // T is U[], C++20, constexpr since C++23
576*bdd1243dSDimitry Andrictemplate<class T, class... Args>
577*bdd1243dSDimitry Andric  unspecified make_unique_for_overwrite(Args&&...) = delete;                  // T is U[N], C++20
578*bdd1243dSDimitry Andric
5790b57cec5SDimitry Andrictemplate<class E, class T, class Y, class D>
5800b57cec5SDimitry Andric    basic_ostream<E, T>& operator<< (basic_ostream<E, T>& os, unique_ptr<Y, D> const& p);
5810b57cec5SDimitry Andric
5820b57cec5SDimitry Andrictemplate<class T>
5830b57cec5SDimitry Andricclass shared_ptr
5840b57cec5SDimitry Andric{
5850b57cec5SDimitry Andricpublic:
586349cc55cSDimitry Andric    typedef T element_type; // until C++17
587349cc55cSDimitry Andric    typedef remove_extent_t<T> element_type; // since C++17
5880b57cec5SDimitry Andric    typedef weak_ptr<T> weak_type; // C++17
5890b57cec5SDimitry Andric
5900b57cec5SDimitry Andric    // constructors:
5910b57cec5SDimitry Andric    constexpr shared_ptr() noexcept;
5920b57cec5SDimitry Andric    template<class Y> explicit shared_ptr(Y* p);
5930b57cec5SDimitry Andric    template<class Y, class D> shared_ptr(Y* p, D d);
5940b57cec5SDimitry Andric    template<class Y, class D, class A> shared_ptr(Y* p, D d, A a);
5950b57cec5SDimitry Andric    template <class D> shared_ptr(nullptr_t p, D d);
5960b57cec5SDimitry Andric    template <class D, class A> shared_ptr(nullptr_t p, D d, A a);
5970b57cec5SDimitry Andric    template<class Y> shared_ptr(const shared_ptr<Y>& r, T *p) noexcept;
5980b57cec5SDimitry Andric    shared_ptr(const shared_ptr& r) noexcept;
5990b57cec5SDimitry Andric    template<class Y> shared_ptr(const shared_ptr<Y>& r) noexcept;
6000b57cec5SDimitry Andric    shared_ptr(shared_ptr&& r) noexcept;
6010b57cec5SDimitry Andric    template<class Y> shared_ptr(shared_ptr<Y>&& r) noexcept;
6020b57cec5SDimitry Andric    template<class Y> explicit shared_ptr(const weak_ptr<Y>& r);
6030b57cec5SDimitry Andric    template<class Y> shared_ptr(auto_ptr<Y>&& r);          // removed in C++17
6040b57cec5SDimitry Andric    template <class Y, class D> shared_ptr(unique_ptr<Y, D>&& r);
6050b57cec5SDimitry Andric    shared_ptr(nullptr_t) : shared_ptr() { }
6060b57cec5SDimitry Andric
6070b57cec5SDimitry Andric    // destructor:
6080b57cec5SDimitry Andric    ~shared_ptr();
6090b57cec5SDimitry Andric
6100b57cec5SDimitry Andric    // assignment:
6110b57cec5SDimitry Andric    shared_ptr& operator=(const shared_ptr& r) noexcept;
6120b57cec5SDimitry Andric    template<class Y> shared_ptr& operator=(const shared_ptr<Y>& r) noexcept;
6130b57cec5SDimitry Andric    shared_ptr& operator=(shared_ptr&& r) noexcept;
6140b57cec5SDimitry Andric    template<class Y> shared_ptr& operator=(shared_ptr<Y>&& r);
6150b57cec5SDimitry Andric    template<class Y> shared_ptr& operator=(auto_ptr<Y>&& r); // removed in C++17
6160b57cec5SDimitry Andric    template <class Y, class D> shared_ptr& operator=(unique_ptr<Y, D>&& r);
6170b57cec5SDimitry Andric
6180b57cec5SDimitry Andric    // modifiers:
6190b57cec5SDimitry Andric    void swap(shared_ptr& r) noexcept;
6200b57cec5SDimitry Andric    void reset() noexcept;
6210b57cec5SDimitry Andric    template<class Y> void reset(Y* p);
6220b57cec5SDimitry Andric    template<class Y, class D> void reset(Y* p, D d);
6230b57cec5SDimitry Andric    template<class Y, class D, class A> void reset(Y* p, D d, A a);
6240b57cec5SDimitry Andric
6250b57cec5SDimitry Andric    // observers:
6260b57cec5SDimitry Andric    T* get() const noexcept;
6270b57cec5SDimitry Andric    T& operator*() const noexcept;
6280b57cec5SDimitry Andric    T* operator->() const noexcept;
6290b57cec5SDimitry Andric    long use_count() const noexcept;
6300b57cec5SDimitry Andric    bool unique() const noexcept;
6310b57cec5SDimitry Andric    explicit operator bool() const noexcept;
6320b57cec5SDimitry Andric    template<class U> bool owner_before(shared_ptr<U> const& b) const noexcept;
6330b57cec5SDimitry Andric    template<class U> bool owner_before(weak_ptr<U> const& b) const noexcept;
6340b57cec5SDimitry Andric};
6350b57cec5SDimitry Andric
6365ffd83dbSDimitry Andrictemplate<class T>
6375ffd83dbSDimitry Andricshared_ptr(weak_ptr<T>) -> shared_ptr<T>;
6385ffd83dbSDimitry Andrictemplate<class T, class D>
6395ffd83dbSDimitry Andricshared_ptr(unique_ptr<T, D>) -> shared_ptr<T>;
6405ffd83dbSDimitry Andric
6410b57cec5SDimitry Andric// shared_ptr comparisons:
6420b57cec5SDimitry Andrictemplate<class T, class U>
6430b57cec5SDimitry Andric    bool operator==(shared_ptr<T> const& a, shared_ptr<U> const& b) noexcept;
6440b57cec5SDimitry Andrictemplate<class T, class U>
645*bdd1243dSDimitry Andric    bool operator!=(shared_ptr<T> const& a, shared_ptr<U> const& b) noexcept;               // removed in C++20
6460b57cec5SDimitry Andrictemplate<class T, class U>
647*bdd1243dSDimitry Andric    bool operator<(shared_ptr<T> const& a, shared_ptr<U> const& b) noexcept;                // removed in C++20
6480b57cec5SDimitry Andrictemplate<class T, class U>
649*bdd1243dSDimitry Andric    bool operator>(shared_ptr<T> const& a, shared_ptr<U> const& b) noexcept;                // removed in C++20
6500b57cec5SDimitry Andrictemplate<class T, class U>
651*bdd1243dSDimitry Andric    bool operator<=(shared_ptr<T> const& a, shared_ptr<U> const& b) noexcept;               // removed in C++20
6520b57cec5SDimitry Andrictemplate<class T, class U>
653*bdd1243dSDimitry Andric    bool operator>=(shared_ptr<T> const& a, shared_ptr<U> const& b) noexcept;               // removed in C++20
654*bdd1243dSDimitry Andrictemplate<class T, class U>
655*bdd1243dSDimitry Andric    strong_ordering operator<=>(shared_ptr<T> const& a, shared_ptr<U> const& b) noexcept;   // C++20
6560b57cec5SDimitry Andric
6570b57cec5SDimitry Andrictemplate <class T>
6580b57cec5SDimitry Andric    bool operator==(const shared_ptr<T>& x, nullptr_t) noexcept;
6590b57cec5SDimitry Andrictemplate <class T>
660*bdd1243dSDimitry Andric    bool operator==(nullptr_t, const shared_ptr<T>& y) noexcept;               // removed in C++20
6610b57cec5SDimitry Andrictemplate <class T>
662*bdd1243dSDimitry Andric    bool operator!=(const shared_ptr<T>& x, nullptr_t) noexcept;               // removed in C++20
6630b57cec5SDimitry Andrictemplate <class T>
664*bdd1243dSDimitry Andric    bool operator!=(nullptr_t, const shared_ptr<T>& y) noexcept;               // removed in C++20
6650b57cec5SDimitry Andrictemplate <class T>
666*bdd1243dSDimitry Andric    bool operator<(const shared_ptr<T>& x, nullptr_t) noexcept;                // removed in C++20
6670b57cec5SDimitry Andrictemplate <class T>
668*bdd1243dSDimitry Andric    bool operator<(nullptr_t, const shared_ptr<T>& y) noexcept;                // removed in C++20
6690b57cec5SDimitry Andrictemplate <class T>
670*bdd1243dSDimitry Andric    bool operator<=(const shared_ptr<T>& x, nullptr_t) noexcept;               // removed in C++20
6710b57cec5SDimitry Andrictemplate <class T>
672*bdd1243dSDimitry Andric    bool operator<=(nullptr_t, const shared_ptr<T>& y) noexcept;               // removed in C++20
6730b57cec5SDimitry Andrictemplate <class T>
674*bdd1243dSDimitry Andric    bool operator>(const shared_ptr<T>& x, nullptr_t) noexcept;                // removed in C++20
6750b57cec5SDimitry Andrictemplate <class T>
676*bdd1243dSDimitry Andric    bool operator>(nullptr_t, const shared_ptr<T>& y) noexcept;                // removed in C++20
6770b57cec5SDimitry Andrictemplate <class T>
678*bdd1243dSDimitry Andric    bool operator>=(const shared_ptr<T>& x, nullptr_t) noexcept;               // removed in C++20
6790b57cec5SDimitry Andrictemplate <class T>
680*bdd1243dSDimitry Andric    bool operator>=(nullptr_t, const shared_ptr<T>& y) noexcept;               // removed in C++20
681*bdd1243dSDimitry Andrictemplate<class T>
682*bdd1243dSDimitry Andric    strong_ordering operator<=>(shared_ptr<T> const& x, nullptr_t) noexcept;   // C++20
6830b57cec5SDimitry Andric
6840b57cec5SDimitry Andric// shared_ptr specialized algorithms:
6850b57cec5SDimitry Andrictemplate<class T> void swap(shared_ptr<T>& a, shared_ptr<T>& b) noexcept;
6860b57cec5SDimitry Andric
6870b57cec5SDimitry Andric// shared_ptr casts:
6880b57cec5SDimitry Andrictemplate<class T, class U>
6890b57cec5SDimitry Andric    shared_ptr<T> static_pointer_cast(shared_ptr<U> const& r) noexcept;
6900b57cec5SDimitry Andrictemplate<class T, class U>
6910b57cec5SDimitry Andric    shared_ptr<T> dynamic_pointer_cast(shared_ptr<U> const& r) noexcept;
6920b57cec5SDimitry Andrictemplate<class T, class U>
6930b57cec5SDimitry Andric    shared_ptr<T> const_pointer_cast(shared_ptr<U> const& r) noexcept;
6940b57cec5SDimitry Andric
6950b57cec5SDimitry Andric// shared_ptr I/O:
6960b57cec5SDimitry Andrictemplate<class E, class T, class Y>
6970b57cec5SDimitry Andric    basic_ostream<E, T>& operator<< (basic_ostream<E, T>& os, shared_ptr<Y> const& p);
6980b57cec5SDimitry Andric
6990b57cec5SDimitry Andric// shared_ptr get_deleter:
7000b57cec5SDimitry Andrictemplate<class D, class T> D* get_deleter(shared_ptr<T> const& p) noexcept;
7010b57cec5SDimitry Andric
7020b57cec5SDimitry Andrictemplate<class T, class... Args>
70381ad6265SDimitry Andric    shared_ptr<T> make_shared(Args&&... args); // T is not an array
7040b57cec5SDimitry Andrictemplate<class T, class A, class... Args>
70581ad6265SDimitry Andric    shared_ptr<T> allocate_shared(const A& a, Args&&... args); // T is not an array
70681ad6265SDimitry Andric
70781ad6265SDimitry Andrictemplate<class T>
70881ad6265SDimitry Andric    shared_ptr<T> make_shared(size_t N); // T is U[] (since C++20)
70981ad6265SDimitry Andrictemplate<class T, class A>
71081ad6265SDimitry Andric    shared_ptr<T> allocate_shared(const A& a, size_t N); // T is U[] (since C++20)
71181ad6265SDimitry Andric
71281ad6265SDimitry Andrictemplate<class T>
71381ad6265SDimitry Andric    shared_ptr<T> make_shared(); // T is U[N] (since C++20)
71481ad6265SDimitry Andrictemplate<class T, class A>
71581ad6265SDimitry Andric    shared_ptr<T> allocate_shared(const A& a); // T is U[N] (since C++20)
71681ad6265SDimitry Andric
71781ad6265SDimitry Andrictemplate<class T>
71881ad6265SDimitry Andric    shared_ptr<T> make_shared(size_t N, const remove_extent_t<T>& u); // T is U[] (since C++20)
71981ad6265SDimitry Andrictemplate<class T, class A>
72081ad6265SDimitry Andric    shared_ptr<T> allocate_shared(const A& a, size_t N, const remove_extent_t<T>& u); // T is U[] (since C++20)
72181ad6265SDimitry Andric
72281ad6265SDimitry Andrictemplate<class T> shared_ptr<T>
72381ad6265SDimitry Andric    make_shared(const remove_extent_t<T>& u); // T is U[N] (since C++20)
72481ad6265SDimitry Andrictemplate<class T, class A>
72581ad6265SDimitry Andric    shared_ptr<T> allocate_shared(const A& a, const remove_extent_t<T>& u); // T is U[N] (since C++20)
7260b57cec5SDimitry Andric
7270b57cec5SDimitry Andrictemplate<class T>
728*bdd1243dSDimitry Andric  shared_ptr<T> make_shared_for_overwrite();                                  // T is not U[], C++20
729*bdd1243dSDimitry Andrictemplate<class T, class A>
730*bdd1243dSDimitry Andric  shared_ptr<T> allocate_shared_for_overwrite(const A& a);                    // T is not U[], C++20
731*bdd1243dSDimitry Andric
732*bdd1243dSDimitry Andrictemplate<class T>
733*bdd1243dSDimitry Andric  shared_ptr<T> make_shared_for_overwrite(size_t N);                          // T is U[], C++20
734*bdd1243dSDimitry Andrictemplate<class T, class A>
735*bdd1243dSDimitry Andric  shared_ptr<T> allocate_shared_for_overwrite(const A& a, size_t N);          // T is U[], C++20
736*bdd1243dSDimitry Andric
737*bdd1243dSDimitry Andrictemplate<class T>
7380b57cec5SDimitry Andricclass weak_ptr
7390b57cec5SDimitry Andric{
7400b57cec5SDimitry Andricpublic:
741349cc55cSDimitry Andric    typedef T element_type; // until C++17
742349cc55cSDimitry Andric    typedef remove_extent_t<T> element_type; // since C++17
7430b57cec5SDimitry Andric
7440b57cec5SDimitry Andric    // constructors
7450b57cec5SDimitry Andric    constexpr weak_ptr() noexcept;
7460b57cec5SDimitry Andric    template<class Y> weak_ptr(shared_ptr<Y> const& r) noexcept;
7470b57cec5SDimitry Andric    weak_ptr(weak_ptr const& r) noexcept;
7480b57cec5SDimitry Andric    template<class Y> weak_ptr(weak_ptr<Y> const& r) noexcept;
7490b57cec5SDimitry Andric    weak_ptr(weak_ptr&& r) noexcept;                      // C++14
7500b57cec5SDimitry Andric    template<class Y> weak_ptr(weak_ptr<Y>&& r) noexcept; // C++14
7510b57cec5SDimitry Andric
7520b57cec5SDimitry Andric    // destructor
7530b57cec5SDimitry Andric    ~weak_ptr();
7540b57cec5SDimitry Andric
7550b57cec5SDimitry Andric    // assignment
7560b57cec5SDimitry Andric    weak_ptr& operator=(weak_ptr const& r) noexcept;
7570b57cec5SDimitry Andric    template<class Y> weak_ptr& operator=(weak_ptr<Y> const& r) noexcept;
7580b57cec5SDimitry Andric    template<class Y> weak_ptr& operator=(shared_ptr<Y> const& r) noexcept;
7590b57cec5SDimitry Andric    weak_ptr& operator=(weak_ptr&& r) noexcept;                      // C++14
7600b57cec5SDimitry Andric    template<class Y> weak_ptr& operator=(weak_ptr<Y>&& r) noexcept; // C++14
7610b57cec5SDimitry Andric
7620b57cec5SDimitry Andric    // modifiers
7630b57cec5SDimitry Andric    void swap(weak_ptr& r) noexcept;
7640b57cec5SDimitry Andric    void reset() noexcept;
7650b57cec5SDimitry Andric
7660b57cec5SDimitry Andric    // observers
7670b57cec5SDimitry Andric    long use_count() const noexcept;
7680b57cec5SDimitry Andric    bool expired() const noexcept;
7690b57cec5SDimitry Andric    shared_ptr<T> lock() const noexcept;
7700b57cec5SDimitry Andric    template<class U> bool owner_before(shared_ptr<U> const& b) const noexcept;
7710b57cec5SDimitry Andric    template<class U> bool owner_before(weak_ptr<U> const& b) const noexcept;
7720b57cec5SDimitry Andric};
7730b57cec5SDimitry Andric
7745ffd83dbSDimitry Andrictemplate<class T>
7755ffd83dbSDimitry Andricweak_ptr(shared_ptr<T>) -> weak_ptr<T>;
7765ffd83dbSDimitry Andric
7770b57cec5SDimitry Andric// weak_ptr specialized algorithms:
7780b57cec5SDimitry Andrictemplate<class T> void swap(weak_ptr<T>& a, weak_ptr<T>& b) noexcept;
7790b57cec5SDimitry Andric
7800b57cec5SDimitry Andric// class owner_less:
7810b57cec5SDimitry Andrictemplate<class T> struct owner_less;
7820b57cec5SDimitry Andric
7830b57cec5SDimitry Andrictemplate<class T>
7840b57cec5SDimitry Andricstruct owner_less<shared_ptr<T> >
7850b57cec5SDimitry Andric    : binary_function<shared_ptr<T>, shared_ptr<T>, bool>
7860b57cec5SDimitry Andric{
7870b57cec5SDimitry Andric    typedef bool result_type;
7880b57cec5SDimitry Andric    bool operator()(shared_ptr<T> const&, shared_ptr<T> const&) const noexcept;
7890b57cec5SDimitry Andric    bool operator()(shared_ptr<T> const&, weak_ptr<T> const&) const noexcept;
7900b57cec5SDimitry Andric    bool operator()(weak_ptr<T> const&, shared_ptr<T> const&) const noexcept;
7910b57cec5SDimitry Andric};
7920b57cec5SDimitry Andric
7930b57cec5SDimitry Andrictemplate<class T>
7940b57cec5SDimitry Andricstruct owner_less<weak_ptr<T> >
7950b57cec5SDimitry Andric    : binary_function<weak_ptr<T>, weak_ptr<T>, bool>
7960b57cec5SDimitry Andric{
7970b57cec5SDimitry Andric    typedef bool result_type;
7980b57cec5SDimitry Andric    bool operator()(weak_ptr<T> const&, weak_ptr<T> const&) const noexcept;
7990b57cec5SDimitry Andric    bool operator()(shared_ptr<T> const&, weak_ptr<T> const&) const noexcept;
8000b57cec5SDimitry Andric    bool operator()(weak_ptr<T> const&, shared_ptr<T> const&) const noexcept;
8010b57cec5SDimitry Andric};
8020b57cec5SDimitry Andric
8030b57cec5SDimitry Andrictemplate <>  // Added in C++14
8040b57cec5SDimitry Andricstruct owner_less<void>
8050b57cec5SDimitry Andric{
8060b57cec5SDimitry Andric    template <class _Tp, class _Up>
8070b57cec5SDimitry Andric    bool operator()( shared_ptr<_Tp> const& __x, shared_ptr<_Up> const& __y) const noexcept;
8080b57cec5SDimitry Andric    template <class _Tp, class _Up>
8090b57cec5SDimitry Andric    bool operator()( shared_ptr<_Tp> const& __x,   weak_ptr<_Up> const& __y) const noexcept;
8100b57cec5SDimitry Andric    template <class _Tp, class _Up>
8110b57cec5SDimitry Andric    bool operator()(   weak_ptr<_Tp> const& __x, shared_ptr<_Up> const& __y) const noexcept;
8120b57cec5SDimitry Andric    template <class _Tp, class _Up>
8130b57cec5SDimitry Andric    bool operator()(   weak_ptr<_Tp> const& __x,   weak_ptr<_Up> const& __y) const noexcept;
8140b57cec5SDimitry Andric
8150b57cec5SDimitry Andric    typedef void is_transparent;
8160b57cec5SDimitry Andric};
8170b57cec5SDimitry Andric
8180b57cec5SDimitry Andrictemplate<class T>
8190b57cec5SDimitry Andricclass enable_shared_from_this
8200b57cec5SDimitry Andric{
8210b57cec5SDimitry Andricprotected:
8220b57cec5SDimitry Andric    constexpr enable_shared_from_this() noexcept;
8230b57cec5SDimitry Andric    enable_shared_from_this(enable_shared_from_this const&) noexcept;
8240b57cec5SDimitry Andric    enable_shared_from_this& operator=(enable_shared_from_this const&) noexcept;
8250b57cec5SDimitry Andric    ~enable_shared_from_this();
8260b57cec5SDimitry Andricpublic:
8270b57cec5SDimitry Andric    shared_ptr<T> shared_from_this();
8280b57cec5SDimitry Andric    shared_ptr<T const> shared_from_this() const;
8290b57cec5SDimitry Andric};
8300b57cec5SDimitry Andric
8310b57cec5SDimitry Andrictemplate<class T>
8320b57cec5SDimitry Andric    bool atomic_is_lock_free(const shared_ptr<T>* p);
8330b57cec5SDimitry Andrictemplate<class T>
8340b57cec5SDimitry Andric    shared_ptr<T> atomic_load(const shared_ptr<T>* p);
8350b57cec5SDimitry Andrictemplate<class T>
8360b57cec5SDimitry Andric    shared_ptr<T> atomic_load_explicit(const shared_ptr<T>* p, memory_order mo);
8370b57cec5SDimitry Andrictemplate<class T>
8380b57cec5SDimitry Andric    void atomic_store(shared_ptr<T>* p, shared_ptr<T> r);
8390b57cec5SDimitry Andrictemplate<class T>
8400b57cec5SDimitry Andric    void atomic_store_explicit(shared_ptr<T>* p, shared_ptr<T> r, memory_order mo);
8410b57cec5SDimitry Andrictemplate<class T>
8420b57cec5SDimitry Andric    shared_ptr<T> atomic_exchange(shared_ptr<T>* p, shared_ptr<T> r);
8430b57cec5SDimitry Andrictemplate<class T>
8440b57cec5SDimitry Andric    shared_ptr<T>
8450b57cec5SDimitry Andric    atomic_exchange_explicit(shared_ptr<T>* p, shared_ptr<T> r, memory_order mo);
8460b57cec5SDimitry Andrictemplate<class T>
8470b57cec5SDimitry Andric    bool
8480b57cec5SDimitry Andric    atomic_compare_exchange_weak(shared_ptr<T>* p, shared_ptr<T>* v, shared_ptr<T> w);
8490b57cec5SDimitry Andrictemplate<class T>
8500b57cec5SDimitry Andric    bool
8510b57cec5SDimitry Andric    atomic_compare_exchange_strong( shared_ptr<T>* p, shared_ptr<T>* v, shared_ptr<T> w);
8520b57cec5SDimitry Andrictemplate<class T>
8530b57cec5SDimitry Andric    bool
8540b57cec5SDimitry Andric    atomic_compare_exchange_weak_explicit(shared_ptr<T>* p, shared_ptr<T>* v,
8550b57cec5SDimitry Andric                                          shared_ptr<T> w, memory_order success,
8560b57cec5SDimitry Andric                                          memory_order failure);
8570b57cec5SDimitry Andrictemplate<class T>
8580b57cec5SDimitry Andric    bool
8590b57cec5SDimitry Andric    atomic_compare_exchange_strong_explicit(shared_ptr<T>* p, shared_ptr<T>* v,
8600b57cec5SDimitry Andric                                            shared_ptr<T> w, memory_order success,
8610b57cec5SDimitry Andric                                            memory_order failure);
8620b57cec5SDimitry Andric// Hash support
8630b57cec5SDimitry Andrictemplate <class T> struct hash;
8640b57cec5SDimitry Andrictemplate <class T, class D> struct hash<unique_ptr<T, D> >;
8650b57cec5SDimitry Andrictemplate <class T> struct hash<shared_ptr<T> >;
8660b57cec5SDimitry Andric
8670b57cec5SDimitry Andrictemplate <class T, class Alloc>
8680b57cec5SDimitry Andric  inline constexpr bool uses_allocator_v = uses_allocator<T, Alloc>::value;
8690b57cec5SDimitry Andric
87081ad6265SDimitry Andric// [ptr.align]
8710b57cec5SDimitry Andricvoid* align(size_t alignment, size_t size, void*& ptr, size_t& space);
8720b57cec5SDimitry Andric
87381ad6265SDimitry Andrictemplate<size_t N, class T>
87481ad6265SDimitry Andric[[nodiscard]] constexpr T* assume_aligned(T* ptr); // since C++20
87581ad6265SDimitry Andric
8760b57cec5SDimitry Andric}  // std
8770b57cec5SDimitry Andric
8780b57cec5SDimitry Andric*/
8790b57cec5SDimitry Andric
88081ad6265SDimitry Andric#include <__assert> // all public C++ headers provide the assertion handler
8810b57cec5SDimitry Andric#include <__config>
882fe6060f1SDimitry Andric#include <__memory/addressof.h>
883*bdd1243dSDimitry Andric#include <__memory/align.h>
88481ad6265SDimitry Andric#include <__memory/allocate_at_least.h>
885fe6060f1SDimitry Andric#include <__memory/allocation_guard.h>
886fe6060f1SDimitry Andric#include <__memory/allocator.h>
887fe6060f1SDimitry Andric#include <__memory/allocator_arg_t.h>
888fe6060f1SDimitry Andric#include <__memory/allocator_traits.h>
88981ad6265SDimitry Andric#include <__memory/assume_aligned.h>
89081ad6265SDimitry Andric#include <__memory/auto_ptr.h>
891fe6060f1SDimitry Andric#include <__memory/compressed_pair.h>
8920eae32dcSDimitry Andric#include <__memory/concepts.h>
893fe6060f1SDimitry Andric#include <__memory/construct_at.h>
894fe6060f1SDimitry Andric#include <__memory/pointer_traits.h>
89504eeddc0SDimitry Andric#include <__memory/ranges_construct_at.h>
8960eae32dcSDimitry Andric#include <__memory/ranges_uninitialized_algorithms.h>
897fe6060f1SDimitry Andric#include <__memory/raw_storage_iterator.h>
898fe6060f1SDimitry Andric#include <__memory/shared_ptr.h>
899fe6060f1SDimitry Andric#include <__memory/temporary_buffer.h>
900fe6060f1SDimitry Andric#include <__memory/uninitialized_algorithms.h>
901fe6060f1SDimitry Andric#include <__memory/unique_ptr.h>
902fe6060f1SDimitry Andric#include <__memory/uses_allocator.h>
903*bdd1243dSDimitry Andric#include <__memory/uses_allocator_construction.h>
9040b57cec5SDimitry Andric#include <version>
9050b57cec5SDimitry Andric
90681ad6265SDimitry Andric// standard-mandated includes
907*bdd1243dSDimitry Andric
908*bdd1243dSDimitry Andric// [memory.syn]
90981ad6265SDimitry Andric#include <compare>
91081ad6265SDimitry Andric
9110b57cec5SDimitry Andric#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
9120b57cec5SDimitry Andric#  pragma GCC system_header
9130b57cec5SDimitry Andric#endif
9140b57cec5SDimitry Andric
915e40139ffSDimitry Andric#if defined(_LIBCPP_HAS_PARALLEL_ALGORITHMS) && _LIBCPP_STD_VER >= 17
916e40139ffSDimitry Andric#   include <__pstl_memory>
917e40139ffSDimitry Andric#endif
918e40139ffSDimitry Andric
919*bdd1243dSDimitry Andric#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
920*bdd1243dSDimitry Andric#  include <concepts>
921*bdd1243dSDimitry Andric#  include <cstddef>
922*bdd1243dSDimitry Andric#  include <cstdint>
923*bdd1243dSDimitry Andric#  include <cstring>
924*bdd1243dSDimitry Andric#  include <iosfwd>
925*bdd1243dSDimitry Andric#  include <iterator>
926*bdd1243dSDimitry Andric#  include <new>
927*bdd1243dSDimitry Andric#  include <stdexcept>
928*bdd1243dSDimitry Andric#  include <tuple>
929*bdd1243dSDimitry Andric#  include <type_traits>
930*bdd1243dSDimitry Andric#  include <typeinfo>
931*bdd1243dSDimitry Andric#  include <utility>
932*bdd1243dSDimitry Andric#endif
933*bdd1243dSDimitry Andric
9340b57cec5SDimitry Andric#endif // _LIBCPP_MEMORY
935