Skip to content

Commit 79df8e1

Browse files
committed
[libc++] Implement P0591R4 (Utility functions to implement uses-allocator construction)
Reviewed By: ldionne, #libc, huixie90 Spies: huixie90, libcxx-commits, mgorny Differential Revision: https://reviews.llvm.org/D131898
1 parent 8e3e962 commit 79df8e1

25 files changed

+948
-22
lines changed

libcxx/docs/ReleaseNotes.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ Implemented Papers
4141
- P2417R2 - A more constexpr bitset
4242
- P2445R1 - ``std::forward_like``
4343
- P2273R3 - Making ``std::unique_ptr`` constexpr
44+
- P0591R4 - Utility functions to implement uses-allocator construction
4445

4546
Improvements and New Features
4647
-----------------------------

libcxx/docs/Status/Cxx20.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ Paper Status
4040

4141
.. note::
4242

43+
.. [#note-P0591] P0591: The changes in [mem.poly.allocator.mem] are missing.
4344
.. [#note-P0600] P0600: The missing bits in P0600 are in |sect|\ [mem.res.class] and |sect|\ [mem.poly.allocator.class].
4445
.. [#note-P0645] P0645: The paper is implemented but still marked as an incomplete feature
4546
(the feature-test macro is not set and the libary is only available when built with ``-fexperimental-library``).

libcxx/docs/Status/Cxx20Issues.csv

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@
149149
"`3169 <https://wg21.link/LWG3169>`__","``ranges``\ permutation generators discard useful information","Cologne","|Complete|","15.0","|ranges|"
150150
"`3183 <https://wg21.link/LWG3183>`__","Normative permission to specialize Ranges variable templates","Cologne","|Nothing To Do|","","|ranges|"
151151
"`3184 <https://wg21.link/LWG3184>`__","Inconsistencies in ``bind_front``\ wording","Cologne","|Complete|","13.0"
152-
"`3185 <https://wg21.link/LWG3185>`__","Uses-allocator construction functions missing ``constexpr``\ and ``noexcept``\ ","Cologne","",""
152+
"`3185 <https://wg21.link/LWG3185>`__","Uses-allocator construction functions missing ``constexpr``\ and ``noexcept``\ ","Cologne","|Complete|","16.0"
153153
"`3186 <https://wg21.link/LWG3186>`__","``ranges``\ removal, partition, and ``partial_sort_copy``\ algorithms discard useful information","Cologne","|Complete|","15.0","|ranges|"
154154
"`3187 <https://wg21.link/LWG3187>`__","`P0591R4 <https://wg21.link/p0591r4>`__ reverted DR 2586 fixes to ``scoped_allocator_adaptor::construct()``\ ","Cologne","",""
155155
"`3191 <https://wg21.link/LWG3191>`__","``std::ranges::shuffle``\ synopsis does not match algorithm definition","Cologne","|Complete|","15.0","|ranges|"
@@ -243,7 +243,7 @@
243243
"`3318 <https://wg21.link/LWG3318>`__","Clarify whether clocks can represent time before their epoch","Prague","","","|chrono|"
244244
"`3319 <https://wg21.link/LWG3319>`__","Properly reference specification of IANA time zone database","Prague","","","|chrono|"
245245
"`3320 <https://wg21.link/LWG3320>`__","``span::cbegin/cend``\ methods produce different results than ``std::[ranges::]cbegin/cend``\ ","Prague","|Complete|",""
246-
"`3321 <https://wg21.link/LWG3321>`__","``uninitialized_construct_using_allocator``\ should use ``construct_at``\ ","Prague","",""
246+
"`3321 <https://wg21.link/LWG3321>`__","``uninitialized_construct_using_allocator``\ should use ``construct_at``\ ","Prague","|Complete|","16.0"
247247
"`3323 <https://wg21.link/LWG3323>`__","``*has-tuple-element*``\ helper concept needs ``convertible_to``\ ","Prague","","","|ranges|"
248248
"`3324 <https://wg21.link/LWG3324>`__","Special-case ``std::strong/weak/partial_order``\ for pointers","Prague","|Complete|","14.0","|spaceship|"
249249
"`3325 <https://wg21.link/LWG3325>`__","Constrain return type of transformation function for ``transform_view``\ ","Prague","|Complete|","15.0","|ranges|"

libcxx/docs/Status/Cxx20Papers.csv

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,8 @@
5555
"`P0357R3 <https://wg21.link/P0357R3>`__","LWG","reference_wrapper for incomplete types","San Diego","|Complete|","8.0"
5656
"`P0482R6 <https://wg21.link/P0482R6>`__","CWG","char8_t: A type for UTF-8 characters and strings","San Diego","|Partial| [#note-P0482]_","16.0"
5757
"`P0487R1 <https://wg21.link/P0487R1>`__","LWG","Fixing ``operator>>(basic_istream&, CharT*)``\ (LWG 2499)","San Diego","|Complete|","8.0"
58-
"`P0591R4 <https://wg21.link/P0591R4>`__","LWG","Utility functions to implement uses-allocator construction","San Diego","* *",""
59-
"`P0595R2 <https://wg21.link/P0595R2>`__","CWG","P0595R2 std::is_constant_evaluated()","San Diego","|Complete|","9.0"
58+
"`P0591R4 <https://wg21.link/P0591R4>`__","LWG","Utility functions to implement uses-allocator construction","San Diego","|Partial| [#note-P0591]_",""
59+
"`P0595R2 <https://wg21.link/P0595R2>`__","CWG","std::is_constant_evaluated()","San Diego","|Complete|","9.0"
6060
"`P0602R4 <https://wg21.link/P0602R4>`__","LWG","variant and optional should propagate copy/move triviality","San Diego","|Complete|","8.0"
6161
"`P0608R3 <https://wg21.link/P0608R3>`__","LWG","A sane variant converting constructor","San Diego","|Complete|","9.0"
6262
"`P0655R1 <https://wg21.link/P0655R1>`__","LWG","visit<R>: Explicit Return Type for visit","San Diego","|Complete|","12.0"

libcxx/docs/Status/ZipProjects.csv

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ Section,Description,Dependencies,Assignee,Complete
44
| `[utility.syn] <https://wg21.link/utility.syn>`_, "[pair] basic_common_reference, common_type", None, Nikolas Klauser, |Complete|
55
| `[pairs.pair] <https://wg21.link/pairs.pair>`_, "`[pair] constructor, assignment and swap overloads <https://reviews.llvm.org/D131495>`_", None, Hui Xie, |Complete|
66
"| `[memory.syn] <https://wg21.link/memory.syn>`_
7-
| `[allocator.uses.construction] <https://wg21.link/allocator.uses.construction>`_", "[pair] uses_allocator_construction_args overloads", None, Unassigned, |Not Started|
7+
| `[allocator.uses.construction] <https://wg21.link/allocator.uses.construction>`_", "[pair] uses_allocator_construction_args overloads", None, Nikolas Klauser, |Complete|
88
| `[vector.bool] <https://wg21.link/vector.bool>`_, "[vector<bool>::reference] add const operator= overload", None, Hui Xie, |Not Started|
99
| `[iterator.concept.winc] <https://wg21.link/iterator.concept.winc>`_, "Update weakly_comparable", None, Hui Xie, |Not Started|
1010
| `[range.zip] <https://wg21.link/ranges.syn>`_, "`zip_view <https://reviews.llvm.org/D122806>`_", "| `zip_view::iterator`

libcxx/include/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -412,6 +412,7 @@ set(files
412412
__memory/uninitialized_algorithms.h
413413
__memory/unique_ptr.h
414414
__memory/uses_allocator.h
415+
__memory/uses_allocator_construction.h
415416
__memory/voidify.h
416417
__mutex_base
417418
__node_handle
Lines changed: 219 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,219 @@
1+
//===----------------------------------------------------------------------===//
2+
//
3+
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4+
// See https://llvm.org/LICENSE.txt for license information.
5+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6+
//
7+
//===----------------------------------------------------------------------===//
8+
9+
#ifndef _LIBCPP___MEMORY_USES_ALLOCATOR_CONSTRUCTION_H
10+
#define _LIBCPP___MEMORY_USES_ALLOCATOR_CONSTRUCTION_H
11+
12+
#include <__config>
13+
#include <__memory/construct_at.h>
14+
#include <__memory/uses_allocator.h>
15+
#include <__type_traits/enable_if.h>
16+
#include <__type_traits/is_same.h>
17+
#include <__utility/pair.h>
18+
#include <tuple>
19+
20+
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
21+
# pragma GCC system_header
22+
#endif
23+
24+
_LIBCPP_BEGIN_NAMESPACE_STD
25+
26+
#if _LIBCPP_STD_VER >= 17
27+
28+
template <class _Type>
29+
inline constexpr bool __is_std_pair = false;
30+
31+
template <class _Type1, class _Type2>
32+
inline constexpr bool __is_std_pair<pair<_Type1, _Type2>> = true;
33+
34+
template <class _Type, class _Alloc, class... _Args, __enable_if_t<!__is_std_pair<_Type>, int> = 0>
35+
_LIBCPP_HIDE_FROM_ABI constexpr auto
36+
__uses_allocator_construction_args(const _Alloc& __alloc, _Args&&... __args) noexcept {
37+
if constexpr (!uses_allocator_v<_Type, _Alloc> && is_constructible_v<_Type, _Args...>) {
38+
return std::forward_as_tuple(std::forward<_Args>(__args)...);
39+
} else if constexpr (uses_allocator_v<_Type, _Alloc> &&
40+
is_constructible_v<_Type, allocator_arg_t, const _Alloc&, _Args...>) {
41+
return tuple<allocator_arg_t, const _Alloc&, _Args&&...>(allocator_arg, __alloc, std::forward<_Args>(__args)...);
42+
} else if constexpr (uses_allocator_v<_Type, _Alloc> && is_constructible_v<_Type, _Args..., const _Alloc&>) {
43+
return std::forward_as_tuple(std::forward<_Args>(__args)..., __alloc);
44+
} else {
45+
static_assert(
46+
sizeof(_Type) + 1 == 0, "If uses_allocator_v<Type> is true, the type has to be allocator-constructible");
47+
}
48+
}
49+
50+
template <class _Pair, class _Alloc, class _Tuple1, class _Tuple2, __enable_if_t<__is_std_pair<_Pair>, int> = 0>
51+
_LIBCPP_HIDE_FROM_ABI constexpr auto __uses_allocator_construction_args(
52+
const _Alloc& __alloc, piecewise_construct_t, _Tuple1&& __x, _Tuple2&& __y) noexcept {
53+
return std::make_tuple(
54+
piecewise_construct,
55+
std::apply(
56+
[&__alloc](auto&&... __args1) {
57+
return std::__uses_allocator_construction_args<typename _Pair::first_type>(
58+
__alloc, std::forward<decltype(__args1)>(__args1)...);
59+
},
60+
std::forward<_Tuple1>(__x)),
61+
std::apply(
62+
[&__alloc](auto&&... __args2) {
63+
return std::__uses_allocator_construction_args<typename _Pair::second_type>(
64+
__alloc, std::forward<decltype(__args2)>(__args2)...);
65+
},
66+
std::forward<_Tuple2>(__y)));
67+
}
68+
69+
template <class _Pair, class _Alloc, __enable_if_t<__is_std_pair<_Pair>, int> = 0>
70+
_LIBCPP_HIDE_FROM_ABI constexpr auto __uses_allocator_construction_args(const _Alloc& __alloc) noexcept {
71+
return std::__uses_allocator_construction_args<_Pair>(__alloc, piecewise_construct, tuple<>{}, tuple<>{});
72+
}
73+
74+
template <class _Pair, class _Alloc, class _Up, class _Vp, __enable_if_t<__is_std_pair<_Pair>, int> = 0>
75+
_LIBCPP_HIDE_FROM_ABI constexpr auto
76+
__uses_allocator_construction_args(const _Alloc& __alloc, _Up&& __u, _Vp&& __v) noexcept {
77+
return std::__uses_allocator_construction_args<_Pair>(
78+
__alloc,
79+
piecewise_construct,
80+
std::forward_as_tuple(std::forward<_Up>(__u)),
81+
std::forward_as_tuple(std::forward<_Vp>(__v)));
82+
}
83+
84+
# if _LIBCPP_STD_VER > 20
85+
template <class _Pair, class _Alloc, class _Up, class _Vp, __enable_if_t<__is_std_pair<_Pair>, int> = 0>
86+
_LIBCPP_HIDE_FROM_ABI constexpr auto
87+
__uses_allocator_construction_args(const _Alloc& __alloc, pair<_Up, _Vp>& __pair) noexcept {
88+
return std::__uses_allocator_construction_args<_Pair>(
89+
__alloc, piecewise_construct, std::forward_as_tuple(__pair.first), std::forward_as_tuple(__pair.second));
90+
}
91+
# endif
92+
93+
template <class _Pair, class _Alloc, class _Up, class _Vp, __enable_if_t<__is_std_pair<_Pair>, int> = 0>
94+
_LIBCPP_HIDE_FROM_ABI constexpr auto
95+
__uses_allocator_construction_args(const _Alloc& __alloc, const pair<_Up, _Vp>& __pair) noexcept {
96+
return std::__uses_allocator_construction_args<_Pair>(
97+
__alloc, piecewise_construct, std::forward_as_tuple(__pair.first), std::forward_as_tuple(__pair.second));
98+
}
99+
100+
template <class _Pair, class _Alloc, class _Up, class _Vp, __enable_if_t<__is_std_pair<_Pair>, int> = 0>
101+
_LIBCPP_HIDE_FROM_ABI constexpr auto
102+
__uses_allocator_construction_args(const _Alloc& __alloc, pair<_Up, _Vp>&& __pair) noexcept {
103+
return std::__uses_allocator_construction_args<_Pair>(
104+
__alloc,
105+
piecewise_construct,
106+
std::forward_as_tuple(std::get<0>(std::move(__pair))),
107+
std::forward_as_tuple(std::get<1>(std::move(__pair))));
108+
}
109+
110+
# if _LIBCPP_STD_VER > 20
111+
template <class _Pair, class _Alloc, class _Up, class _Vp, __enable_if_t<__is_std_pair<_Pair>, int> = 0>
112+
_LIBCPP_HIDE_FROM_ABI constexpr auto
113+
__uses_allocator_construction_args(const _Alloc& __alloc, const pair<_Up, _Vp>&& __pair) noexcept {
114+
return std::__uses_allocator_construction_args<_Pair>(
115+
__alloc,
116+
piecewise_construct,
117+
std::forward_as_tuple(std::get<0>(std::move(__pair))),
118+
std::forward_as_tuple(std::get<1>(std::move(__pair))));
119+
}
120+
# endif
121+
122+
namespace __uses_allocator_detail {
123+
124+
template <class _Ap, class _Bp>
125+
void __fun(const pair<_Ap, _Bp>&);
126+
127+
template <class _Tp>
128+
decltype(__uses_allocator_detail::__fun(std::declval<_Tp>()), true_type()) __convertible_to_const_pair_ref_impl(int);
129+
130+
template <class>
131+
false_type __convertible_to_const_pair_ref_impl(...);
132+
133+
template <class _Tp>
134+
inline constexpr bool __convertible_to_const_pair_ref =
135+
decltype(__uses_allocator_detail::__convertible_to_const_pair_ref_impl<_Tp>(0))::value;
136+
137+
} // namespace __uses_allocator_detail
138+
139+
template <
140+
class _Pair,
141+
class _Alloc,
142+
class _Type,
143+
__enable_if_t<__is_std_pair<_Pair> && !__uses_allocator_detail::__convertible_to_const_pair_ref<_Type>, int> = 0>
144+
_LIBCPP_HIDE_FROM_ABI constexpr auto
145+
__uses_allocator_construction_args(const _Alloc& __alloc, _Type&& __value) noexcept;
146+
147+
template <class _Type, class _Alloc, class... _Args>
148+
_LIBCPP_HIDE_FROM_ABI constexpr _Type __make_obj_using_allocator(const _Alloc& __alloc, _Args&&... __args);
149+
150+
template <class _Pair,
151+
class _Alloc,
152+
class _Type,
153+
__enable_if_t<__is_std_pair<_Pair> && !__uses_allocator_detail::__convertible_to_const_pair_ref<_Type>, int>>
154+
_LIBCPP_HIDE_FROM_ABI constexpr auto
155+
__uses_allocator_construction_args(const _Alloc& __alloc, _Type&& __value) noexcept {
156+
struct __pair_constructor {
157+
using _PairMutable = remove_cv_t<_Pair>;
158+
159+
_LIBCPP_HIDE_FROM_ABI constexpr auto __do_construct(const _PairMutable& __pair) const {
160+
return std::__make_obj_using_allocator<_PairMutable>(__alloc_, __pair);
161+
}
162+
163+
_LIBCPP_HIDE_FROM_ABI constexpr auto __do_construct(_PairMutable&& __pair) const {
164+
return std::__make_obj_using_allocator<_PairMutable>(__alloc_, std::move(__pair));
165+
}
166+
167+
const _Alloc& __alloc_;
168+
_Type& __value_;
169+
170+
_LIBCPP_HIDE_FROM_ABI constexpr operator _PairMutable() const {
171+
return __do_construct(std::forward<_Type>(this->__value_));
172+
}
173+
};
174+
175+
return std::make_tuple(__pair_constructor{__alloc, __value});
176+
}
177+
178+
template <class _Type, class _Alloc, class... _Args>
179+
_LIBCPP_HIDE_FROM_ABI constexpr _Type __make_obj_using_allocator(const _Alloc& __alloc, _Args&&... __args) {
180+
return std::make_from_tuple<_Type>(
181+
std::__uses_allocator_construction_args<_Type>(__alloc, std::forward<_Args>(__args)...));
182+
}
183+
184+
template <class _Type, class _Alloc, class... _Args>
185+
_LIBCPP_HIDE_FROM_ABI constexpr _Type*
186+
__uninitialized_construct_using_allocator(_Type* __ptr, const _Alloc& __alloc, _Args&&... __args) {
187+
return std::apply(
188+
[&__ptr](auto&&... __xs) { return std::__construct_at(__ptr, std::forward<decltype(__xs)>(__xs)...); },
189+
std::__uses_allocator_construction_args<_Type>(__alloc, std::forward<_Args>(__args)...));
190+
}
191+
192+
#endif // _LIBCPP_STD_VER >= 17
193+
194+
#if _LIBCPP_STD_VER >= 20
195+
196+
template <class _Type, class _Alloc, class... _Args>
197+
_LIBCPP_HIDE_FROM_ABI constexpr auto uses_allocator_construction_args(const _Alloc& __alloc, _Args&&... __args) noexcept
198+
-> decltype(std::__uses_allocator_construction_args<_Type>(__alloc, std::forward<_Args>(__args)...)) {
199+
return /*--*/ std::__uses_allocator_construction_args<_Type>(__alloc, std::forward<_Args>(__args)...);
200+
}
201+
202+
template <class _Type, class _Alloc, class... _Args>
203+
_LIBCPP_HIDE_FROM_ABI constexpr auto make_obj_using_allocator(const _Alloc& __alloc, _Args&&... __args)
204+
-> decltype(std::__make_obj_using_allocator<_Type>(__alloc, std::forward<_Args>(__args)...)) {
205+
return /*--*/ std::__make_obj_using_allocator<_Type>(__alloc, std::forward<_Args>(__args)...);
206+
}
207+
208+
template <class _Type, class _Alloc, class... _Args>
209+
_LIBCPP_HIDE_FROM_ABI constexpr auto
210+
uninitialized_construct_using_allocator(_Type* __ptr, const _Alloc& __alloc, _Args&&... __args)
211+
-> decltype(std::__uninitialized_construct_using_allocator(__ptr, __alloc, std::forward<_Args>(__args)...)) {
212+
return /*--*/ std::__uninitialized_construct_using_allocator(__ptr, __alloc, std::forward<_Args>(__args)...);
213+
}
214+
215+
#endif // _LIBCPP_STD_VER >= 20
216+
217+
_LIBCPP_END_NAMESPACE_STD
218+
219+
#endif // _LIBCPP___MEMORY_USES_ALLOCATOR_CONSTRUCTION_H

libcxx/include/memory

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -883,6 +883,7 @@ template<size_t N, class T>
883883
#include <__memory/uninitialized_algorithms.h>
884884
#include <__memory/unique_ptr.h>
885885
#include <__memory/uses_allocator.h>
886+
#include <__memory/uses_allocator_construction.h>
886887
#include <version>
887888

888889
// standard-mandated includes

libcxx/include/module.modulemap.in

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -878,6 +878,7 @@ module std [system] {
878878
module uninitialized_algorithms { private header "__memory/uninitialized_algorithms.h" }
879879
module unique_ptr { private header "__memory/unique_ptr.h" }
880880
module uses_allocator { private header "__memory/uses_allocator.h" }
881+
module uses_allocator_construction { private header "__memory/uses_allocator_construction.h" }
881882
module voidify { private header "__memory/voidify.h" }
882883
}
883884
}

libcxx/include/scoped_allocator

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,7 @@ template <class OuterA1, class OuterA2, class... InnerAllocs>
112112
#include <__assert> // all public C++ headers provide the assertion handler
113113
#include <__config>
114114
#include <__memory/allocator_traits.h>
115+
#include <__memory/uses_allocator_construction.h>
115116
#include <__type_traits/common_type.h>
116117
#include <__type_traits/enable_if.h>
117118
#include <__type_traits/integral_constant.h>
@@ -523,6 +524,18 @@ public:
523524
size_type max_size() const
524525
{return allocator_traits<outer_allocator_type>::max_size(outer_allocator());}
525526

527+
#if _LIBCPP_STD_VER >= 20
528+
template <class _Type, class... _Args>
529+
_LIBCPP_HIDE_FROM_ABI void construct(_Type* __ptr, _Args&&... __args) {
530+
using _OM = __outermost<outer_allocator_type>;
531+
std::apply(
532+
[__ptr, this](auto&&... __newargs) {
533+
allocator_traits<typename _OM::type>::construct(
534+
_OM()(outer_allocator()), __ptr, std::forward<decltype(__newargs)>(__newargs)...);
535+
},
536+
std::uses_allocator_construction_args<_Type>(inner_allocator(), std::forward<_Args>(__args)...));
537+
}
538+
#else
526539
template <class _Tp, class... _Args>
527540
_LIBCPP_INLINE_VISIBILITY
528541
void construct(_Tp* __p, _Args&& ...__args)
@@ -577,6 +590,7 @@ public:
577590
_VSTD::forward_as_tuple(_VSTD::forward<_Up>(__x.first)),
578591
_VSTD::forward_as_tuple(_VSTD::forward<_Vp>(__x.second)));
579592
}
593+
#endif
580594

581595
template <class _Tp>
582596
_LIBCPP_INLINE_VISIBILITY

libcxx/test/libcxx/private_headers.verify.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -443,6 +443,7 @@ END-SCRIPT
443443
#include <__memory/uninitialized_algorithms.h> // expected-error@*:* {{use of private header from outside its module: '__memory/uninitialized_algorithms.h'}}
444444
#include <__memory/unique_ptr.h> // expected-error@*:* {{use of private header from outside its module: '__memory/unique_ptr.h'}}
445445
#include <__memory/uses_allocator.h> // expected-error@*:* {{use of private header from outside its module: '__memory/uses_allocator.h'}}
446+
#include <__memory/uses_allocator_construction.h> // expected-error@*:* {{use of private header from outside its module: '__memory/uses_allocator_construction.h'}}
446447
#include <__memory/voidify.h> // expected-error@*:* {{use of private header from outside its module: '__memory/voidify.h'}}
447448
#include <__mutex_base> // expected-error@*:* {{use of private header from outside its module: '__mutex_base'}}
448449
#include <__node_handle> // expected-error@*:* {{use of private header from outside its module: '__node_handle'}}

libcxx/test/libcxx/transitive_includes/cxx2b.csv

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -479,6 +479,7 @@ memory iosfwd
479479
memory limits
480480
memory new
481481
memory stdexcept
482+
memory tuple
482483
memory type_traits
483484
memory typeinfo
484485
memory version

libcxx/test/std/utilities/allocator.adaptor/allocator.adaptor.members/construct.pass.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -115,10 +115,10 @@ struct G
115115
{
116116
static bool constructed;
117117

118-
typedef std::allocator<G> allocator_type;
118+
typedef std::scoped_allocator_adaptor<std::allocator<G>> allocator_type;
119119

120120
G(std::allocator_arg_t, allocator_type&&) { assert(false); }
121-
G(allocator_type&) { constructed = true; }
121+
G(const allocator_type&) { constructed = true; }
122122
};
123123

124124
bool G::constructed = false;
@@ -202,7 +202,7 @@ int main(int, char**)
202202
// Test that is_constructible uses an lvalue ref so the correct constructor
203203
// is picked.
204204
{
205-
std::scoped_allocator_adaptor<G::allocator_type> sa;
205+
G::allocator_type sa;
206206
G* ptr = sa.allocate(1);
207207
sa.construct(ptr);
208208
assert(G::constructed);

0 commit comments

Comments
 (0)