From 56a9632f0b643d7f7963c695c3626fa437684b08 Mon Sep 17 00:00:00 2001 From: Igor Zhukov Date: Thu, 9 Sep 2021 22:15:30 +0700 Subject: [PATCH 1/4] implement LWG3527 --- stl/inc/xmemory | 6 +++--- tests/std/test.lst | 1 + .../env.lst | 4 ++++ .../test.compile.pass.cpp | 20 +++++++++++++++++++ 4 files changed, 28 insertions(+), 3 deletions(-) create mode 100644 tests/std/tests/LWG3527_uses_allocator_construction_args/env.lst create mode 100644 tests/std/tests/LWG3527_uses_allocator_construction_args/test.compile.pass.cpp diff --git a/stl/inc/xmemory b/stl/inc/xmemory index 8b5111a7f8..571ae5207d 100644 --- a/stl/inc/xmemory +++ b/stl/inc/xmemory @@ -2140,10 +2140,10 @@ template && _Pair) noexcept { // equivalent to // return _STD uses_allocator_construction_args<_Ty>(_Al, piecewise_construct, - // _STD forward_as_tuple(_STD move(_Pair).first), _STD forward_as_tuple(_STD move(_Pair).second)); + // _STD forward_as_tuple(get<0>(_STD move(_Pair)), _STD forward_as_tuple(get<1>(_STD move(_Pair))); return _STD make_tuple(piecewise_construct, - _STD uses_allocator_construction_args(_Al, _STD move(_Pair).first), - _STD uses_allocator_construction_args(_Al, _STD move(_Pair).second)); + _STD uses_allocator_construction_args(_Al, get<0>(_STD move(_Pair))), + _STD uses_allocator_construction_args(_Al, get<1>(_STD move(_Pair)))); } template diff --git a/tests/std/test.lst b/tests/std/test.lst index 4993a4e59e..ba1709330e 100644 --- a/tests/std/test.lst +++ b/tests/std/test.lst @@ -183,6 +183,7 @@ tests\GH_002058_debug_iterator_race tests\GH_002120_streambuf_seekpos_and_seekoff tests\LWG2597_complex_branch_cut tests\LWG3018_shared_ptr_function +tests\LWG3527_uses_allocator_construction_args tests\P0019R8_atomic_ref tests\P0024R2_parallel_algorithms_adjacent_difference tests\P0024R2_parallel_algorithms_adjacent_find diff --git a/tests/std/tests/LWG3527_uses_allocator_construction_args/env.lst b/tests/std/tests/LWG3527_uses_allocator_construction_args/env.lst new file mode 100644 index 0000000000..351a8293d9 --- /dev/null +++ b/tests/std/tests/LWG3527_uses_allocator_construction_args/env.lst @@ -0,0 +1,4 @@ +# Copyright (c) Microsoft Corporation. +# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + +RUNALL_INCLUDE ..\usual_20_matrix.lst diff --git a/tests/std/tests/LWG3527_uses_allocator_construction_args/test.compile.pass.cpp b/tests/std/tests/LWG3527_uses_allocator_construction_args/test.compile.pass.cpp new file mode 100644 index 0000000000..0a6dd65059 --- /dev/null +++ b/tests/std/tests/LWG3527_uses_allocator_construction_args/test.compile.pass.cpp @@ -0,0 +1,20 @@ +// Copyright (c) Microsoft Corporation. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + +#include +#include + +using namespace std; + +struct MoveOnlyType { + MoveOnlyType() = default; + MoveOnlyType(MoveOnlyType&&) = default; +}; + +void test() { + std::allocator alloc; + [[maybe_unused]] auto p = pair{MoveOnlyType{}, MoveOnlyType{}}; + [[maybe_unused]] auto t = uses_allocator_construction_args>(alloc, move(p)); +} + +int main() {} // COMPILE-ONLY From b54584984910d8333a29be73479ce3ae92a23bd7 Mon Sep 17 00:00:00 2001 From: Igor Zhukov Date: Thu, 9 Sep 2021 22:32:26 +0700 Subject: [PATCH 2/4] move test code to P0475R1_P0591R4_uses_allocator_construction Co-authored-by: Adam Bucior <35536269+AdamBucior@users.noreply.github.com> --- tests/std/test.lst | 1 - .../env.lst | 4 ---- .../test.compile.pass.cpp | 20 ------------------- .../test.cpp | 11 ++++++++++ 4 files changed, 11 insertions(+), 25 deletions(-) delete mode 100644 tests/std/tests/LWG3527_uses_allocator_construction_args/env.lst delete mode 100644 tests/std/tests/LWG3527_uses_allocator_construction_args/test.compile.pass.cpp diff --git a/tests/std/test.lst b/tests/std/test.lst index ba1709330e..4993a4e59e 100644 --- a/tests/std/test.lst +++ b/tests/std/test.lst @@ -183,7 +183,6 @@ tests\GH_002058_debug_iterator_race tests\GH_002120_streambuf_seekpos_and_seekoff tests\LWG2597_complex_branch_cut tests\LWG3018_shared_ptr_function -tests\LWG3527_uses_allocator_construction_args tests\P0019R8_atomic_ref tests\P0024R2_parallel_algorithms_adjacent_difference tests\P0024R2_parallel_algorithms_adjacent_find diff --git a/tests/std/tests/LWG3527_uses_allocator_construction_args/env.lst b/tests/std/tests/LWG3527_uses_allocator_construction_args/env.lst deleted file mode 100644 index 351a8293d9..0000000000 --- a/tests/std/tests/LWG3527_uses_allocator_construction_args/env.lst +++ /dev/null @@ -1,4 +0,0 @@ -# Copyright (c) Microsoft Corporation. -# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception - -RUNALL_INCLUDE ..\usual_20_matrix.lst diff --git a/tests/std/tests/LWG3527_uses_allocator_construction_args/test.compile.pass.cpp b/tests/std/tests/LWG3527_uses_allocator_construction_args/test.compile.pass.cpp deleted file mode 100644 index 0a6dd65059..0000000000 --- a/tests/std/tests/LWG3527_uses_allocator_construction_args/test.compile.pass.cpp +++ /dev/null @@ -1,20 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception - -#include -#include - -using namespace std; - -struct MoveOnlyType { - MoveOnlyType() = default; - MoveOnlyType(MoveOnlyType&&) = default; -}; - -void test() { - std::allocator alloc; - [[maybe_unused]] auto p = pair{MoveOnlyType{}, MoveOnlyType{}}; - [[maybe_unused]] auto t = uses_allocator_construction_args>(alloc, move(p)); -} - -int main() {} // COMPILE-ONLY diff --git a/tests/std/tests/P0475R1_P0591R4_uses_allocator_construction/test.cpp b/tests/std/tests/P0475R1_P0591R4_uses_allocator_construction/test.cpp index 71d5103359..2842619314 100644 --- a/tests/std/tests/P0475R1_P0591R4_uses_allocator_construction/test.cpp +++ b/tests/std/tests/P0475R1_P0591R4_uses_allocator_construction/test.cpp @@ -179,6 +179,17 @@ void test_GH_2021() { // COMPILE-ONLY tags[0]; } +struct MoveOnlyType { + MoveOnlyType() = default; + MoveOnlyType(MoveOnlyType&&) = default; +}; + +void test_LWG3527() { // COMPILE-ONLY + std::allocator alloc; + [[maybe_unused]] auto p = pair{MoveOnlyType{}, MoveOnlyType{}}; + [[maybe_unused]] auto t = uses_allocator_construction_args>(alloc, move(p)); +} + int main() { test_P0475R1(); From 68818c7b473da14e892d6b3ef31f8caea354d205 Mon Sep 17 00:00:00 2001 From: Igor Zhukov Date: Thu, 9 Sep 2021 22:37:55 +0700 Subject: [PATCH 3/4] p is actually used :) Co-authored-by: Alex Guteniev --- .../tests/P0475R1_P0591R4_uses_allocator_construction/test.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/std/tests/P0475R1_P0591R4_uses_allocator_construction/test.cpp b/tests/std/tests/P0475R1_P0591R4_uses_allocator_construction/test.cpp index 2842619314..246192a2ea 100644 --- a/tests/std/tests/P0475R1_P0591R4_uses_allocator_construction/test.cpp +++ b/tests/std/tests/P0475R1_P0591R4_uses_allocator_construction/test.cpp @@ -186,7 +186,7 @@ struct MoveOnlyType { void test_LWG3527() { // COMPILE-ONLY std::allocator alloc; - [[maybe_unused]] auto p = pair{MoveOnlyType{}, MoveOnlyType{}}; + auto p = pair{MoveOnlyType{}, MoveOnlyType{}}; [[maybe_unused]] auto t = uses_allocator_construction_args>(alloc, move(p)); } From 0f8b0c1035ec3a05f13a6ebfffa8048809b4ebdf Mon Sep 17 00:00:00 2001 From: "Stephan T. Lavavej" Date: Thu, 9 Sep 2021 12:35:08 -0700 Subject: [PATCH 4/4] Code review feedback. --- stl/inc/xmemory | 6 +++--- .../P0475R1_P0591R4_uses_allocator_construction/test.cpp | 5 +++-- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/stl/inc/xmemory b/stl/inc/xmemory index 571ae5207d..9447bf7ff0 100644 --- a/stl/inc/xmemory +++ b/stl/inc/xmemory @@ -2140,10 +2140,10 @@ template && _Pair) noexcept { // equivalent to // return _STD uses_allocator_construction_args<_Ty>(_Al, piecewise_construct, - // _STD forward_as_tuple(get<0>(_STD move(_Pair)), _STD forward_as_tuple(get<1>(_STD move(_Pair))); + // _STD forward_as_tuple(_STD get<0>(_STD move(_Pair)), _STD forward_as_tuple(_STD get<1>(_STD move(_Pair))); return _STD make_tuple(piecewise_construct, - _STD uses_allocator_construction_args(_Al, get<0>(_STD move(_Pair))), - _STD uses_allocator_construction_args(_Al, get<1>(_STD move(_Pair)))); + _STD uses_allocator_construction_args(_Al, _STD get<0>(_STD move(_Pair))), + _STD uses_allocator_construction_args(_Al, _STD get<1>(_STD move(_Pair)))); } template diff --git a/tests/std/tests/P0475R1_P0591R4_uses_allocator_construction/test.cpp b/tests/std/tests/P0475R1_P0591R4_uses_allocator_construction/test.cpp index 246192a2ea..291eae8ae3 100644 --- a/tests/std/tests/P0475R1_P0591R4_uses_allocator_construction/test.cpp +++ b/tests/std/tests/P0475R1_P0591R4_uses_allocator_construction/test.cpp @@ -185,8 +185,9 @@ struct MoveOnlyType { }; void test_LWG3527() { // COMPILE-ONLY - std::allocator alloc; - auto p = pair{MoveOnlyType{}, MoveOnlyType{}}; + allocator alloc; + MoveOnlyType obj; + pair p{move(obj), move(obj)}; [[maybe_unused]] auto t = uses_allocator_construction_args>(alloc, move(p)); }