[libcxx-commits] [libcxx] [libc++] LWG 3821 uses_allocator_construction_args should have overload for pair-like (PR #66939)
Louis Dionne via libcxx-commits
libcxx-commits at lists.llvm.org
Wed Sep 27 09:17:19 PDT 2023
================
@@ -132,19 +133,48 @@ constexpr bool test() {
}
#endif
{
- ConvertibleToPair ctp {};
- auto ret = test_uses_allocator_construction_args<std::pair<int, int>>(a, ctp);
+ ConvertibleToPair ctp{};
+ auto ret = test_uses_allocator_construction_args<std::pair<int, int>>(a, ctp);
std::pair<int, int> v = std::get<0>(ret);
assert(std::get<0>(v) == 1);
assert(std::get<1>(v) == 2);
}
{
- ConvertibleToPair ctp {};
- auto ret = test_uses_allocator_construction_args<std::pair<int, int>>(a, std::move(ctp));
+ ConvertibleToPair ctp{};
+ auto ret = test_uses_allocator_construction_args<std::pair<int, int>>(a, std::move(ctp));
std::pair<int, int> v = std::get<0>(ret);
assert(std::get<0>(v) == 1);
assert(std::get<1>(v) == 2);
}
+#if TEST_STD_VER >= 23
+ // LWG 3821
+ // uses_allocator_construction_args should have overload for pair-like
+ {
+ // pair-like with explicit ctr should work
+ struct Foo {
+ int i = 5;
+ };
+ struct Bar {
+ int i;
+ constexpr explicit Bar(Foo foo) : i(foo.i) {}
+ };
+
+ std::tuple<Foo, Foo> pair_like;
+ auto ret = test_uses_allocator_construction_args<std::pair<Bar, Bar>>(a, pair_like);
+ auto pair = std::make_from_tuple<std::pair<Bar, Bar>>(std::move(ret));
+ assert(pair.first.i == 5);
+ assert(pair.second.i == 5);
+ }
+ {
+ // subrange should work
+ int i = 5;
+ std::ranges::subrange<int*, int*> r{&i, &i};
+ auto ret = std::__uses_allocator_construction_args<std::pair<int*, int*>>(a, r);
----------------
ldionne wrote:
We shouldn't be using the private version here! I guess you should be using `test_uses_allocator_construction_args` here instead.
https://github.com/llvm/llvm-project/pull/66939
More information about the libcxx-commits
mailing list