diff --git a/stl/inc/type_traits b/stl/inc/type_traits index 995c15966ce..2aa95b03e48 100644 --- a/stl/inc/type_traits +++ b/stl/inc/type_traits @@ -1842,7 +1842,7 @@ void ref(const _Ty&&) = delete; template _NODISCARD _CONSTEXPR20 reference_wrapper<_Ty> ref(reference_wrapper<_Ty> _Val) noexcept { - return _STD ref(_Val.get()); + return _Val; } template @@ -1855,7 +1855,7 @@ void cref(const _Ty&&) = delete; template _NODISCARD _CONSTEXPR20 reference_wrapper cref(reference_wrapper<_Ty> _Val) noexcept { - return _STD cref(_Val.get()); + return _Val; } #if _HAS_CXX20 diff --git a/tests/std/test.lst b/tests/std/test.lst index 83422b1229f..eb23654d7e4 100644 --- a/tests/std/test.lst +++ b/tests/std/test.lst @@ -192,6 +192,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\LWG3146_excessive_unwrapping_ref_cref tests\LWG3422_seed_seq_ctors tests\LWG3480_directory_iterator_range tests\P0019R8_atomic_ref diff --git a/tests/std/tests/LWG3146_excessive_unwrapping_ref_cref/env.lst b/tests/std/tests/LWG3146_excessive_unwrapping_ref_cref/env.lst new file mode 100644 index 00000000000..19f025bd0e6 --- /dev/null +++ b/tests/std/tests/LWG3146_excessive_unwrapping_ref_cref/env.lst @@ -0,0 +1,4 @@ +# Copyright (c) Microsoft Corporation. +# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + +RUNALL_INCLUDE ..\usual_matrix.lst diff --git a/tests/std/tests/LWG3146_excessive_unwrapping_ref_cref/test.compile.pass.cpp b/tests/std/tests/LWG3146_excessive_unwrapping_ref_cref/test.compile.pass.cpp new file mode 100644 index 00000000000..52971d585cb --- /dev/null +++ b/tests/std/tests/LWG3146_excessive_unwrapping_ref_cref/test.compile.pass.cpp @@ -0,0 +1,23 @@ +// Copyright (c) Microsoft Corporation. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + +#include +#include + +using namespace std; + +void test_LWG_3146() { + int i = 0; + reference_wrapper ri(i); + reference_wrapper> rri(ri); + + auto reference = ref(rri); + auto const_reference = cref(rri); + + static_assert( + is_same_v>>, "LWG-3146 is not implemented"); + static_assert(is_same_v>>, + "LWG-3146 is not implemented"); +} + +int main() {} // COMPILE-ONLY