From 34161050d5ed23deb5344dca7e2dafcc9ee5807e Mon Sep 17 00:00:00 2001 From: yronglin Date: Sun, 24 Mar 2024 17:15:01 +0800 Subject: [PATCH 01/28] : Make std::make_from_tuple and std::_Make_from_tuple_impl SFINAE friendly Signed-off-by: yronglin --- stl/inc/tuple | 33 +++++- .../LWG3528_make_from_tuple_impl/env.lst | 4 + .../test.compile.pass.cpp | 103 ++++++++++++++++++ .../LWG3545_pointer_traits_sfinae/env.lst | 2 +- 4 files changed, 136 insertions(+), 6 deletions(-) create mode 100644 tests/std/tests/LWG3528_make_from_tuple_impl/env.lst create mode 100644 tests/std/tests/LWG3528_make_from_tuple_impl/test.compile.pass.cpp diff --git a/stl/inc/tuple b/stl/inc/tuple index c49a9205c5f..469b5971db3 100644 --- a/stl/inc/tuple +++ b/stl/inc/tuple @@ -1079,23 +1079,46 @@ constexpr decltype(auto) apply(_Callable&& _Obj, _Tuple&& _Tpl) noexcept( make_index_sequence>>{}); } +#if _HAS_CXX20 #if _HAS_CXX23 template #else // ^^^ _HAS_CXX23 / !_HAS_CXX23 vvv template #endif // ^^^ !_HAS_CXX23 ^^^ -constexpr _Ty _Make_from_tuple_impl(_Tuple&& _Tpl, index_sequence<_Indices...>) noexcept( - is_nothrow_constructible_v<_Ty, decltype(_STD get<_Indices>(_STD forward<_Tuple>(_Tpl)))...>) { - // construct _Ty from the elements of _Tpl - static_assert(is_constructible_v<_Ty, decltype(_STD get<_Indices>(_STD forward<_Tuple>(_Tpl)))...>, - "the target type must be constructible from the fields of the argument tuple (N4950 [tuple.apply]/4)."); + requires is_constructible_v<_Ty, decltype(_STD get<_Indices>(_STD declval<_Tuple>()))...> +constexpr _Ty _Make_from_tuple_impl(_Tuple&& _Tpl, index_sequence<_Indices...>) +#else // ^^^ _HAS_CXX20 / !_HAS_CXX20 vvv +template +constexpr _Ty _Make_from_tuple_impl(_Tuple&& _Tpl, index_sequence<_Indices...>, + enable_if_t(_STD forward<_Tuple>(_Tpl)))...>, int> = 0) +#endif // ^^^ !_HAS_CXX20 ^^^ + noexcept(is_nothrow_constructible_v<_Ty, decltype(_STD get<_Indices>(_STD forward<_Tuple>(_Tpl)))...>) { return _Ty(_STD get<_Indices>(_STD forward<_Tuple>(_Tpl))...); } +#if _HAS_CXX23 +template >>, class = void> +_INLINE_VAR constexpr bool _Can_make_from_tuple = false; +template +_INLINE_VAR constexpr bool _Can_make_from_tuple<_Ty, _Tuple, index_sequence<_Indices...>, + enable_if_t(_STD declval<_Tuple>()))...>>> = true; +#else // ^^^ _HAS_CXX23 / !_HAS_CXX23 vvv +template >>, class = void> +_INLINE_VAR constexpr bool _Can_make_from_tuple = false; +template +_INLINE_VAR constexpr bool _Can_make_from_tuple<_Ty, _Tuple, index_sequence<_Indices...>, + enable_if_t(_STD declval<_Tuple>()))...>>> = true; +#endif // ^^^ !_HAS_CXX23 ^^^ + +#if _HAS_CXX20 #if _HAS_CXX23 _EXPORT_STD template #else // ^^^ _HAS_CXX23 / !_HAS_CXX23 vvv _EXPORT_STD template +#endif // ^^^ !_HAS_CXX23 ^^^ + requires _Can_make_from_tuple<_Ty, _Tuple> +#else // ^^^ _HAS_CXX20 / !_HAS_CXX20 vvv +_EXPORT_STD template , int> = 0> #endif // ^^^ !_HAS_CXX23 ^^^ _NODISCARD constexpr _Ty make_from_tuple(_Tuple&& _Tpl) noexcept(noexcept(_STD _Make_from_tuple_impl<_Ty>( _STD forward<_Tuple>(_Tpl), make_index_sequence>>{}))) /* strengthened */ { diff --git a/tests/std/tests/LWG3528_make_from_tuple_impl/env.lst b/tests/std/tests/LWG3528_make_from_tuple_impl/env.lst new file mode 100644 index 00000000000..2de7aab2959 --- /dev/null +++ b/tests/std/tests/LWG3528_make_from_tuple_impl/env.lst @@ -0,0 +1,4 @@ +# Copyright (c) Microsoft Corporation. +# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + +RUNALL_INCLUDE ..\usual_17_matrix.lst diff --git a/tests/std/tests/LWG3528_make_from_tuple_impl/test.compile.pass.cpp b/tests/std/tests/LWG3528_make_from_tuple_impl/test.compile.pass.cpp new file mode 100644 index 00000000000..7a8a265d6bf --- /dev/null +++ b/tests/std/tests/LWG3528_make_from_tuple_impl/test.compile.pass.cpp @@ -0,0 +1,103 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// +// Copyright (c) Microsoft Corporation. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +//===----------------------------------------------------------------------===// + +#include +#include +#include + +struct A { + int a; +}; +struct B : public A {}; + +struct C { + C(const B&) {} +}; + +enum class D { + ONE, + TWO, +}; + +template +auto can_make_from_tuple(T&&, Tuple&& t) -> decltype(std::make_from_tuple(t), uint8_t()) { + return 0; +} +template +uint32_t can_make_from_tuple(...) { + return 0; +} + +template +inline constexpr bool has_make_from_tuple = + std::is_same_v(T{}, Tuple{})), uint8_t>; + +template +auto can_make_from_tuple_impl(T&&, Tuple&& t) + -> decltype(std::_Make_from_tuple_impl(std::forward(t), + std::make_index_sequence>>{}), + uint8_t()) { + return 0; +} +template +uint32_t can_make_from_tuple_impl(...) { + return 0; +} + +template +inline constexpr bool has_make_from_tuple_impl = + std::is_same_v(T{}, Tuple{})), uint8_t>; + +// Test std::make_from_tuple constraints. + +// reinterpret_cast +static_assert(!has_make_from_tuple>); +static_assert(has_make_from_tuple>); + +// const_cast +static_assert(!has_make_from_tuple>); +static_assert(!has_make_from_tuple>); +static_assert(has_make_from_tuple>); +static_assert(has_make_from_tuple>); +static_assert(has_make_from_tuple>); +static_assert(has_make_from_tuple>); + +// static_cast +static_assert(!has_make_from_tuple>); +static_assert(!has_make_from_tuple>); +static_assert(has_make_from_tuple>); +static_assert(has_make_from_tuple>); +static_assert(has_make_from_tuple>); + +// Test std::__Make_from_tuple_impl constraints. + +// reinterpret_cast +static_assert(!has_make_from_tuple_impl>); +static_assert(has_make_from_tuple_impl>); + +// const_cast +static_assert(!has_make_from_tuple_impl>); +static_assert(!has_make_from_tuple_impl>); +static_assert(has_make_from_tuple_impl>); +static_assert(has_make_from_tuple_impl>); +static_assert(has_make_from_tuple_impl>); +static_assert(has_make_from_tuple_impl>); + +// static_cast +static_assert(!has_make_from_tuple_impl>); +static_assert(!has_make_from_tuple_impl>); +static_assert(has_make_from_tuple_impl>); +static_assert(has_make_from_tuple_impl>); +static_assert(has_make_from_tuple_impl>); + +int main() { + return 0; +} diff --git a/tests/std/tests/LWG3545_pointer_traits_sfinae/env.lst b/tests/std/tests/LWG3545_pointer_traits_sfinae/env.lst index 19f025bd0e6..2de7aab2959 100644 --- a/tests/std/tests/LWG3545_pointer_traits_sfinae/env.lst +++ b/tests/std/tests/LWG3545_pointer_traits_sfinae/env.lst @@ -1,4 +1,4 @@ # Copyright (c) Microsoft Corporation. # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -RUNALL_INCLUDE ..\usual_matrix.lst +RUNALL_INCLUDE ..\usual_17_matrix.lst From 731c99836060798b0d97ffd0fa3a5f05066cde33 Mon Sep 17 00:00:00 2001 From: yronglin Date: Sun, 24 Mar 2024 17:52:27 +0800 Subject: [PATCH 02/28] Format Signed-off-by: yronglin --- stl/inc/tuple | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/stl/inc/tuple b/stl/inc/tuple index 469b5971db3..378547a8422 100644 --- a/stl/inc/tuple +++ b/stl/inc/tuple @@ -1097,13 +1097,15 @@ constexpr _Ty _Make_from_tuple_impl(_Tuple&& _Tpl, index_sequence<_Indices...>, } #if _HAS_CXX23 -template >>, class = void> +template >>, + class = void> _INLINE_VAR constexpr bool _Can_make_from_tuple = false; template _INLINE_VAR constexpr bool _Can_make_from_tuple<_Ty, _Tuple, index_sequence<_Indices...>, enable_if_t(_STD declval<_Tuple>()))...>>> = true; #else // ^^^ _HAS_CXX23 / !_HAS_CXX23 vvv -template >>, class = void> +template >>, + class = void> _INLINE_VAR constexpr bool _Can_make_from_tuple = false; template _INLINE_VAR constexpr bool _Can_make_from_tuple<_Ty, _Tuple, index_sequence<_Indices...>, @@ -1124,7 +1126,7 @@ _NODISCARD constexpr _Ty make_from_tuple(_Tuple&& _Tpl) noexcept(noexcept(_STD _ _STD forward<_Tuple>(_Tpl), make_index_sequence>>{}))) /* strengthened */ { // construct _Ty from the elements of _Tpl return _STD _Make_from_tuple_impl<_Ty>( - _STD forward<_Tuple>(_Tpl), make_index_sequence>>{}); + _STD forward<_Tuple>(_Tpl), make_index_sequence>>{} ); } #endif // _HAS_CXX17 From 959808daf23239b1cbf507143d608ca129f3f787 Mon Sep 17 00:00:00 2001 From: yronglin Date: Sun, 24 Mar 2024 17:59:12 +0800 Subject: [PATCH 03/28] Format Signed-off-by: yronglin --- stl/inc/tuple | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stl/inc/tuple b/stl/inc/tuple index 378547a8422..ff50fc0f82f 100644 --- a/stl/inc/tuple +++ b/stl/inc/tuple @@ -1126,7 +1126,7 @@ _NODISCARD constexpr _Ty make_from_tuple(_Tuple&& _Tpl) noexcept(noexcept(_STD _ _STD forward<_Tuple>(_Tpl), make_index_sequence>>{}))) /* strengthened */ { // construct _Ty from the elements of _Tpl return _STD _Make_from_tuple_impl<_Ty>( - _STD forward<_Tuple>(_Tpl), make_index_sequence>>{} ); + _STD forward<_Tuple>(_Tpl), make_index_sequence>>{}); } #endif // _HAS_CXX17 From e41ba981b0875eba554b8fa0045a512a3ddcc5cd Mon Sep 17 00:00:00 2001 From: yronglin Date: Sun, 24 Mar 2024 18:05:32 +0800 Subject: [PATCH 04/28] Revert incorrect change Signed-off-by: yronglin --- tests/std/tests/LWG3545_pointer_traits_sfinae/env.lst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/std/tests/LWG3545_pointer_traits_sfinae/env.lst b/tests/std/tests/LWG3545_pointer_traits_sfinae/env.lst index 2de7aab2959..19f025bd0e6 100644 --- a/tests/std/tests/LWG3545_pointer_traits_sfinae/env.lst +++ b/tests/std/tests/LWG3545_pointer_traits_sfinae/env.lst @@ -1,4 +1,4 @@ # Copyright (c) Microsoft Corporation. # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -RUNALL_INCLUDE ..\usual_17_matrix.lst +RUNALL_INCLUDE ..\usual_matrix.lst From 2133da6736301e62c0048e33e2107c4674d88067 Mon Sep 17 00:00:00 2001 From: yronglin Date: Mon, 25 Mar 2024 23:06:03 +0800 Subject: [PATCH 05/28] : Address review comments and add more test Signed-off-by: yronglin --- stl/inc/tuple | 27 +-- .../test.compile.pass.cpp | 163 ++++++++++++++++-- 2 files changed, 154 insertions(+), 36 deletions(-) diff --git a/stl/inc/tuple b/stl/inc/tuple index ff50fc0f82f..841aa2c30e9 100644 --- a/stl/inc/tuple +++ b/stl/inc/tuple @@ -1079,39 +1079,30 @@ constexpr decltype(auto) apply(_Callable&& _Obj, _Tuple&& _Tpl) noexcept( make_index_sequence>>{}); } +template >>, + class = void> +inline constexpr bool _Can_make_from_tuple = false; +template +inline constexpr bool _Can_make_from_tuple<_Ty, _Tuple, index_sequence<_Indices...>, + enable_if_t(_STD declval<_Tuple>()))...>>> = true; + #if _HAS_CXX20 #if _HAS_CXX23 template #else // ^^^ _HAS_CXX23 / !_HAS_CXX23 vvv template #endif // ^^^ !_HAS_CXX23 ^^^ - requires is_constructible_v<_Ty, decltype(_STD get<_Indices>(_STD declval<_Tuple>()))...> + requires _Can_make_from_tuple<_Ty, _Tuple> constexpr _Ty _Make_from_tuple_impl(_Tuple&& _Tpl, index_sequence<_Indices...>) #else // ^^^ _HAS_CXX20 / !_HAS_CXX20 vvv template constexpr _Ty _Make_from_tuple_impl(_Tuple&& _Tpl, index_sequence<_Indices...>, - enable_if_t(_STD forward<_Tuple>(_Tpl)))...>, int> = 0) + enable_if_t<_Can_make_from_tuple<_Ty, _Tuple>, int> = 0) #endif // ^^^ !_HAS_CXX20 ^^^ noexcept(is_nothrow_constructible_v<_Ty, decltype(_STD get<_Indices>(_STD forward<_Tuple>(_Tpl)))...>) { return _Ty(_STD get<_Indices>(_STD forward<_Tuple>(_Tpl))...); } -#if _HAS_CXX23 -template >>, - class = void> -_INLINE_VAR constexpr bool _Can_make_from_tuple = false; -template -_INLINE_VAR constexpr bool _Can_make_from_tuple<_Ty, _Tuple, index_sequence<_Indices...>, - enable_if_t(_STD declval<_Tuple>()))...>>> = true; -#else // ^^^ _HAS_CXX23 / !_HAS_CXX23 vvv -template >>, - class = void> -_INLINE_VAR constexpr bool _Can_make_from_tuple = false; -template -_INLINE_VAR constexpr bool _Can_make_from_tuple<_Ty, _Tuple, index_sequence<_Indices...>, - enable_if_t(_STD declval<_Tuple>()))...>>> = true; -#endif // ^^^ !_HAS_CXX23 ^^^ - #if _HAS_CXX20 #if _HAS_CXX23 _EXPORT_STD template diff --git a/tests/std/tests/LWG3528_make_from_tuple_impl/test.compile.pass.cpp b/tests/std/tests/LWG3528_make_from_tuple_impl/test.compile.pass.cpp index 7a8a265d6bf..feceff0057c 100644 --- a/tests/std/tests/LWG3528_make_from_tuple_impl/test.compile.pass.cpp +++ b/tests/std/tests/LWG3528_make_from_tuple_impl/test.compile.pass.cpp @@ -9,9 +9,11 @@ // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception //===----------------------------------------------------------------------===// +#include #include #include #include +#include struct A { int a; @@ -37,8 +39,8 @@ uint32_t can_make_from_tuple(...) { } template -inline constexpr bool has_make_from_tuple = - std::is_same_v(T{}, Tuple{})), uint8_t>; +inline constexpr bool has_make_from_tuple_sfinae = + std::is_same_v(std::declval(), std::declval())), uint8_t>; template auto can_make_from_tuple_impl(T&&, Tuple&& t) @@ -53,16 +55,43 @@ uint32_t can_make_from_tuple_impl(...) { } template -inline constexpr bool has_make_from_tuple_impl = - std::is_same_v(T{}, Tuple{})), uint8_t>; - -// Test std::make_from_tuple constraints. - -// reinterpret_cast +inline constexpr bool has_make_from_tuple_impl_sfinae = + std::is_same_v(std::declval(), std::declval())), uint8_t>; + +template >>, + class = void> +inline constexpr bool has_make_from_tuple = false; +template +inline constexpr bool has_make_from_tuple<_Ty, _Tuple, std::index_sequence<_Indices...>, + std::void_t(std::declval<_Tuple>()))>> = true; + +template >>, class = void> +inline constexpr bool has_make_from_tuple_impl = false; +template +inline constexpr bool has_make_from_tuple_impl<_Ty, _Tuple, std::index_sequence<_Indices...>, + std::void_t(std::declval<_Tuple>(), + std::declval>>>()))>> = true; + +// Test std::make_from_tuple. + +// reinterpret_cast && std::tuple && partial specialization static_assert(!has_make_from_tuple>); static_assert(has_make_from_tuple>); -// const_cast +// reinterpret_cast && std::array && partial specialization +static_assert(!has_make_from_tuple>); +static_assert(has_make_from_tuple>); + +// reinterpret_cast && std::tuple && SFINAE +static_assert(!has_make_from_tuple_sfinae>); +static_assert(has_make_from_tuple_sfinae>); + +// reinterpret_cast && std::array && SFINAE +static_assert(!has_make_from_tuple_sfinae>); +static_assert(has_make_from_tuple_sfinae>); + +// const_cast && std::tuple && partial specialization static_assert(!has_make_from_tuple>); static_assert(!has_make_from_tuple>); static_assert(has_make_from_tuple>); @@ -70,20 +99,77 @@ static_assert(has_make_from_tuple>); static_assert(has_make_from_tuple>); static_assert(has_make_from_tuple>); -// static_cast +// const_cast && std::array && partial specialization +static_assert(!has_make_from_tuple>); +static_assert(!has_make_from_tuple>); +static_assert(has_make_from_tuple>); +static_assert(has_make_from_tuple>); +static_assert(has_make_from_tuple>); +static_assert(has_make_from_tuple>); + +// const_cast && std::tuple && SFINAE +static_assert(!has_make_from_tuple_sfinae>); +static_assert(!has_make_from_tuple_sfinae>); +static_assert(has_make_from_tuple_sfinae>); +static_assert(has_make_from_tuple_sfinae>); +static_assert(has_make_from_tuple_sfinae>); +static_assert(has_make_from_tuple_sfinae>); + +// const_cast && std::array && SFINAE +static_assert(!has_make_from_tuple_sfinae>); +static_assert(!has_make_from_tuple_sfinae>); +static_assert(has_make_from_tuple_sfinae>); +static_assert(has_make_from_tuple_sfinae>); +static_assert(has_make_from_tuple_sfinae>); +static_assert(has_make_from_tuple_sfinae>); + +// static_cast && std::tuple && partial specialization static_assert(!has_make_from_tuple>); static_assert(!has_make_from_tuple>); static_assert(has_make_from_tuple>); static_assert(has_make_from_tuple>); static_assert(has_make_from_tuple>); -// Test std::__Make_from_tuple_impl constraints. - -// reinterpret_cast +// static_cast && std::array && partial specialization +static_assert(!has_make_from_tuple>); +static_assert(!has_make_from_tuple>); +static_assert(has_make_from_tuple>); +static_assert(has_make_from_tuple>); +static_assert(has_make_from_tuple>); + +// static_cast && std::tuple && SFINAE +static_assert(!has_make_from_tuple_sfinae>); +static_assert(!has_make_from_tuple_sfinae>); +static_assert(has_make_from_tuple_sfinae>); +static_assert(has_make_from_tuple_sfinae>); +static_assert(has_make_from_tuple_sfinae>); + +// static_cast && std::array && SFINAE +static_assert(!has_make_from_tuple_sfinae>); +static_assert(!has_make_from_tuple_sfinae>); +static_assert(has_make_from_tuple_sfinae>); +static_assert(has_make_from_tuple_sfinae>); +static_assert(has_make_from_tuple_sfinae>); + +// Test std::__Make_from_tuple_impl. + +// reinterpret_cast && std::tuple && partial specialization static_assert(!has_make_from_tuple_impl>); static_assert(has_make_from_tuple_impl>); -// const_cast +// reinterpret_cast && std::array && partial specialization +static_assert(!has_make_from_tuple_impl>); +static_assert(has_make_from_tuple_impl>); + +// reinterpret_cast && std::tuple && SFINAE +static_assert(!has_make_from_tuple_impl_sfinae>); +static_assert(has_make_from_tuple_impl_sfinae>); + +// reinterpret_cast && std::array && SFINAE +static_assert(!has_make_from_tuple_impl_sfinae>); +static_assert(has_make_from_tuple_impl_sfinae>); + +// const_cast && std::tuple && partial specialization static_assert(!has_make_from_tuple_impl>); static_assert(!has_make_from_tuple_impl>); static_assert(has_make_from_tuple_impl>); @@ -91,13 +177,54 @@ static_assert(has_make_from_tuple_impl>); static_assert(has_make_from_tuple_impl>); static_assert(has_make_from_tuple_impl>); -// static_cast +// const_cast && std::array && partial specialization +static_assert(!has_make_from_tuple_impl>); +static_assert(!has_make_from_tuple_impl>); +static_assert(has_make_from_tuple_impl>); +static_assert(has_make_from_tuple_impl>); +static_assert(has_make_from_tuple_impl>); +static_assert(has_make_from_tuple_impl>); + +// const_cast && std::tuple && SFINAE +static_assert(!has_make_from_tuple_impl_sfinae>); +static_assert(!has_make_from_tuple_impl_sfinae>); +static_assert(has_make_from_tuple_impl_sfinae>); +static_assert(has_make_from_tuple_impl_sfinae>); +static_assert(has_make_from_tuple_impl_sfinae>); +static_assert(has_make_from_tuple_impl_sfinae>); + +// const_cast && std::array && SFINAE +static_assert(!has_make_from_tuple_impl_sfinae>); +static_assert(!has_make_from_tuple_impl_sfinae>); +static_assert(has_make_from_tuple_impl_sfinae>); +static_assert(has_make_from_tuple_impl_sfinae>); +static_assert(has_make_from_tuple_impl_sfinae>); +static_assert(has_make_from_tuple_impl_sfinae>); + +// static_cast && std::tuple && partial specialization static_assert(!has_make_from_tuple_impl>); static_assert(!has_make_from_tuple_impl>); static_assert(has_make_from_tuple_impl>); static_assert(has_make_from_tuple_impl>); static_assert(has_make_from_tuple_impl>); -int main() { - return 0; -} +// static_cast && std::array && partial specialization +static_assert(!has_make_from_tuple_impl>); +static_assert(!has_make_from_tuple_impl>); +static_assert(has_make_from_tuple_impl>); +static_assert(has_make_from_tuple_impl>); +static_assert(has_make_from_tuple_impl>); + +// static_cast && std::tuple && SFINAE +static_assert(!has_make_from_tuple_impl_sfinae>); +static_assert(!has_make_from_tuple_impl_sfinae>); +static_assert(has_make_from_tuple_impl_sfinae>); +static_assert(has_make_from_tuple_impl_sfinae>); +static_assert(has_make_from_tuple_impl_sfinae>); + +// static_cast && std::array && SFINAE +static_assert(!has_make_from_tuple_impl_sfinae>); +static_assert(!has_make_from_tuple_impl_sfinae>); +static_assert(has_make_from_tuple_impl_sfinae>); +static_assert(has_make_from_tuple_impl_sfinae>); +static_assert(has_make_from_tuple_impl_sfinae>); From 1276f61b0e3b62ca27501b52d4b8c79b92672466 Mon Sep 17 00:00:00 2001 From: yronglin Date: Mon, 25 Mar 2024 23:16:44 +0800 Subject: [PATCH 06/28] Format Signed-off-by: yronglin --- stl/inc/tuple | 4 ++-- .../LWG3528_make_from_tuple_impl/test.compile.pass.cpp | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/stl/inc/tuple b/stl/inc/tuple index 841aa2c30e9..729ade8970e 100644 --- a/stl/inc/tuple +++ b/stl/inc/tuple @@ -1096,8 +1096,8 @@ template constexpr _Ty _Make_from_tuple_impl(_Tuple&& _Tpl, index_sequence<_Indices...>) #else // ^^^ _HAS_CXX20 / !_HAS_CXX20 vvv template -constexpr _Ty _Make_from_tuple_impl(_Tuple&& _Tpl, index_sequence<_Indices...>, - enable_if_t<_Can_make_from_tuple<_Ty, _Tuple>, int> = 0) +constexpr _Ty _Make_from_tuple_impl( + _Tuple&& _Tpl, index_sequence<_Indices...>, enable_if_t<_Can_make_from_tuple<_Ty, _Tuple>, int> = 0) #endif // ^^^ !_HAS_CXX20 ^^^ noexcept(is_nothrow_constructible_v<_Ty, decltype(_STD get<_Indices>(_STD forward<_Tuple>(_Tpl)))...>) { return _Ty(_STD get<_Indices>(_STD forward<_Tuple>(_Tpl))...); diff --git a/tests/std/tests/LWG3528_make_from_tuple_impl/test.compile.pass.cpp b/tests/std/tests/LWG3528_make_from_tuple_impl/test.compile.pass.cpp index feceff0057c..64d9b8dade8 100644 --- a/tests/std/tests/LWG3528_make_from_tuple_impl/test.compile.pass.cpp +++ b/tests/std/tests/LWG3528_make_from_tuple_impl/test.compile.pass.cpp @@ -40,7 +40,7 @@ uint32_t can_make_from_tuple(...) { template inline constexpr bool has_make_from_tuple_sfinae = - std::is_same_v(std::declval(), std::declval())), uint8_t>; + std::is_same_v(std::declval(), std::declval())), uint8_t>; template auto can_make_from_tuple_impl(T&&, Tuple&& t) @@ -58,8 +58,8 @@ template inline constexpr bool has_make_from_tuple_impl_sfinae = std::is_same_v(std::declval(), std::declval())), uint8_t>; -template >>, - class = void> +template >>, class = void> inline constexpr bool has_make_from_tuple = false; template inline constexpr bool has_make_from_tuple<_Ty, _Tuple, std::index_sequence<_Indices...>, From 83347f004475039321b3de6ac75f5f1ddf593fd3 Mon Sep 17 00:00:00 2001 From: yronglin Date: Tue, 26 Mar 2024 19:50:05 +0800 Subject: [PATCH 07/28] Address review comments and format Signed-off-by: yronglin --- .../LWG3528_make_from_tuple_impl/test.compile.pass.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/tests/std/tests/LWG3528_make_from_tuple_impl/test.compile.pass.cpp b/tests/std/tests/LWG3528_make_from_tuple_impl/test.compile.pass.cpp index 64d9b8dade8..b8b0199d222 100644 --- a/tests/std/tests/LWG3528_make_from_tuple_impl/test.compile.pass.cpp +++ b/tests/std/tests/LWG3528_make_from_tuple_impl/test.compile.pass.cpp @@ -18,6 +18,7 @@ struct A { int a; }; + struct B : public A {}; struct C { @@ -25,14 +26,15 @@ struct C { }; enum class D { - ONE, - TWO, + one, + two, }; template auto can_make_from_tuple(T&&, Tuple&& t) -> decltype(std::make_from_tuple(t), uint8_t()) { return 0; } + template uint32_t can_make_from_tuple(...) { return 0; @@ -49,6 +51,7 @@ auto can_make_from_tuple_impl(T&&, Tuple&& t) uint8_t()) { return 0; } + template uint32_t can_make_from_tuple_impl(...) { return 0; @@ -61,6 +64,7 @@ inline constexpr bool has_make_from_tuple_impl_sfinae = template >>, class = void> inline constexpr bool has_make_from_tuple = false; + template inline constexpr bool has_make_from_tuple<_Ty, _Tuple, std::index_sequence<_Indices...>, std::void_t(std::declval<_Tuple>()))>> = true; @@ -68,6 +72,7 @@ inline constexpr bool has_make_from_tuple<_Ty, _Tuple, std::index_sequence<_Indi template >>, class = void> inline constexpr bool has_make_from_tuple_impl = false; + template inline constexpr bool has_make_from_tuple_impl<_Ty, _Tuple, std::index_sequence<_Indices...>, std::void_t(std::declval<_Tuple>(), From 13a6ab6f65eadf68d80f51eacb1094b8a6b29e07 Mon Sep 17 00:00:00 2001 From: "Stephan T. Lavavej" Date: Tue, 26 Mar 2024 06:20:17 -0700 Subject: [PATCH 08/28] Add new test to tests/std/test.lst. --- tests/std/test.lst | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/std/test.lst b/tests/std/test.lst index f854b835230..39dfd7cafe5 100644 --- a/tests/std/test.lst +++ b/tests/std/test.lst @@ -249,6 +249,7 @@ tests\LWG3146_excessive_unwrapping_ref_cref tests\LWG3234_math_special_overloads tests\LWG3422_seed_seq_ctors tests\LWG3480_directory_iterator_range +tests\LWG3528_make_from_tuple_impl tests\LWG3545_pointer_traits_sfinae tests\LWG3561_discard_block_engine_counter tests\LWG3610_iota_view_size_and_integer_class From f7ff18ccfc0e801196a69cdb1db0c5fe0862f8e9 Mon Sep 17 00:00:00 2001 From: "Stephan T. Lavavej" Date: Tue, 26 Mar 2024 06:27:46 -0700 Subject: [PATCH 09/28] Mention libc++'s test files. --- .../tests/LWG3528_make_from_tuple_impl/test.compile.pass.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tests/std/tests/LWG3528_make_from_tuple_impl/test.compile.pass.cpp b/tests/std/tests/LWG3528_make_from_tuple_impl/test.compile.pass.cpp index b8b0199d222..80ace431cc1 100644 --- a/tests/std/tests/LWG3528_make_from_tuple_impl/test.compile.pass.cpp +++ b/tests/std/tests/LWG3528_make_from_tuple_impl/test.compile.pass.cpp @@ -9,6 +9,9 @@ // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception //===----------------------------------------------------------------------===// +// derived from libc++'s test files: +// * std/utilities/tuple/tuple.tuple/tuple.apply/make_from_tuple.pass.cpp + #include #include #include From ab8644fa16cf714673e705c390b1497efa2289a8 Mon Sep 17 00:00:00 2001 From: "Stephan T. Lavavej" Date: Tue, 26 Mar 2024 06:34:05 -0700 Subject: [PATCH 10/28] Add `std::` qualification to `` types. --- .../test.compile.pass.cpp | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/tests/std/tests/LWG3528_make_from_tuple_impl/test.compile.pass.cpp b/tests/std/tests/LWG3528_make_from_tuple_impl/test.compile.pass.cpp index 80ace431cc1..5253f082f62 100644 --- a/tests/std/tests/LWG3528_make_from_tuple_impl/test.compile.pass.cpp +++ b/tests/std/tests/LWG3528_make_from_tuple_impl/test.compile.pass.cpp @@ -34,35 +34,36 @@ enum class D { }; template -auto can_make_from_tuple(T&&, Tuple&& t) -> decltype(std::make_from_tuple(t), uint8_t()) { +auto can_make_from_tuple(T&&, Tuple&& t) -> decltype(std::make_from_tuple(t), std::uint8_t()) { return 0; } template -uint32_t can_make_from_tuple(...) { +std::uint32_t can_make_from_tuple(...) { return 0; } template inline constexpr bool has_make_from_tuple_sfinae = - std::is_same_v(std::declval(), std::declval())), uint8_t>; + std::is_same_v(std::declval(), std::declval())), std::uint8_t>; template auto can_make_from_tuple_impl(T&&, Tuple&& t) -> decltype(std::_Make_from_tuple_impl(std::forward(t), std::make_index_sequence>>{}), - uint8_t()) { + std::uint8_t()) { return 0; } template -uint32_t can_make_from_tuple_impl(...) { +std::uint32_t can_make_from_tuple_impl(...) { return 0; } template inline constexpr bool has_make_from_tuple_impl_sfinae = - std::is_same_v(std::declval(), std::declval())), uint8_t>; + std::is_same_v(std::declval(), std::declval())), + std::uint8_t>; template >>, class = void> From 3073394c5eef7c6fa2acbfb05eacdda1bac202f4 Mon Sep 17 00:00:00 2001 From: "Stephan T. Lavavej" Date: Tue, 26 Mar 2024 06:37:18 -0700 Subject: [PATCH 11/28] Style: Use empty braces for `std::uint8_t{}` temporaries. --- .../tests/LWG3528_make_from_tuple_impl/test.compile.pass.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/std/tests/LWG3528_make_from_tuple_impl/test.compile.pass.cpp b/tests/std/tests/LWG3528_make_from_tuple_impl/test.compile.pass.cpp index 5253f082f62..366ccaf3361 100644 --- a/tests/std/tests/LWG3528_make_from_tuple_impl/test.compile.pass.cpp +++ b/tests/std/tests/LWG3528_make_from_tuple_impl/test.compile.pass.cpp @@ -34,7 +34,7 @@ enum class D { }; template -auto can_make_from_tuple(T&&, Tuple&& t) -> decltype(std::make_from_tuple(t), std::uint8_t()) { +auto can_make_from_tuple(T&&, Tuple&& t) -> decltype(std::make_from_tuple(t), std::uint8_t{}) { return 0; } @@ -51,7 +51,7 @@ template auto can_make_from_tuple_impl(T&&, Tuple&& t) -> decltype(std::_Make_from_tuple_impl(std::forward(t), std::make_index_sequence>>{}), - std::uint8_t()) { + std::uint8_t{}) { return 0; } From ab204113c1538e78c73c0ebe6e0793a50c97fe91 Mon Sep 17 00:00:00 2001 From: "Stephan T. Lavavej" Date: Tue, 26 Mar 2024 06:41:00 -0700 Subject: [PATCH 12/28] Directly construct `make_index_sequence{}`, no need for `declval`. --- .../tests/LWG3528_make_from_tuple_impl/test.compile.pass.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/std/tests/LWG3528_make_from_tuple_impl/test.compile.pass.cpp b/tests/std/tests/LWG3528_make_from_tuple_impl/test.compile.pass.cpp index 366ccaf3361..2500649648f 100644 --- a/tests/std/tests/LWG3528_make_from_tuple_impl/test.compile.pass.cpp +++ b/tests/std/tests/LWG3528_make_from_tuple_impl/test.compile.pass.cpp @@ -80,7 +80,7 @@ inline constexpr bool has_make_from_tuple_impl = false; template inline constexpr bool has_make_from_tuple_impl<_Ty, _Tuple, std::index_sequence<_Indices...>, std::void_t(std::declval<_Tuple>(), - std::declval>>>()))>> = true; + std::make_index_sequence>>{}))>> = true; // Test std::make_from_tuple. From 26ef5d264e9294980671147b5caf45195176cbbe Mon Sep 17 00:00:00 2001 From: "Stephan T. Lavavej" Date: Tue, 26 Mar 2024 06:44:21 -0700 Subject: [PATCH 13/28] Rename `_Ugly` identifiers: `_Ty` => `T` --- .../test.compile.pass.cpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/tests/std/tests/LWG3528_make_from_tuple_impl/test.compile.pass.cpp b/tests/std/tests/LWG3528_make_from_tuple_impl/test.compile.pass.cpp index 2500649648f..6eb64dc0244 100644 --- a/tests/std/tests/LWG3528_make_from_tuple_impl/test.compile.pass.cpp +++ b/tests/std/tests/LWG3528_make_from_tuple_impl/test.compile.pass.cpp @@ -65,21 +65,21 @@ inline constexpr bool has_make_from_tuple_impl_sfinae = std::is_same_v(std::declval(), std::declval())), std::uint8_t>; -template >>, class = void> inline constexpr bool has_make_from_tuple = false; -template -inline constexpr bool has_make_from_tuple<_Ty, _Tuple, std::index_sequence<_Indices...>, - std::void_t(std::declval<_Tuple>()))>> = true; +template +inline constexpr bool has_make_from_tuple, + std::void_t(std::declval<_Tuple>()))>> = true; -template >>, class = void> inline constexpr bool has_make_from_tuple_impl = false; -template -inline constexpr bool has_make_from_tuple_impl<_Ty, _Tuple, std::index_sequence<_Indices...>, - std::void_t(std::declval<_Tuple>(), +template +inline constexpr bool has_make_from_tuple_impl, + std::void_t(std::declval<_Tuple>(), std::make_index_sequence>>{}))>> = true; // Test std::make_from_tuple. From d65d9e6d698d5f2518b48d47aa603887357a5643 Mon Sep 17 00:00:00 2001 From: "Stephan T. Lavavej" Date: Tue, 26 Mar 2024 06:45:45 -0700 Subject: [PATCH 14/28] Rename `_Ugly` identifiers: `_Tuple` => `Tuple` --- .../test.compile.pass.cpp | 22 +++++++++---------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/tests/std/tests/LWG3528_make_from_tuple_impl/test.compile.pass.cpp b/tests/std/tests/LWG3528_make_from_tuple_impl/test.compile.pass.cpp index 6eb64dc0244..45c4db515b5 100644 --- a/tests/std/tests/LWG3528_make_from_tuple_impl/test.compile.pass.cpp +++ b/tests/std/tests/LWG3528_make_from_tuple_impl/test.compile.pass.cpp @@ -65,22 +65,22 @@ inline constexpr bool has_make_from_tuple_impl_sfinae = std::is_same_v(std::declval(), std::declval())), std::uint8_t>; -template >>, class = void> +template >>, class = void> inline constexpr bool has_make_from_tuple = false; -template -inline constexpr bool has_make_from_tuple, - std::void_t(std::declval<_Tuple>()))>> = true; +template +inline constexpr bool has_make_from_tuple, + std::void_t(std::declval()))>> = true; -template >>, class = void> +template >>, class = void> inline constexpr bool has_make_from_tuple_impl = false; -template -inline constexpr bool has_make_from_tuple_impl, - std::void_t(std::declval<_Tuple>(), - std::make_index_sequence>>{}))>> = true; +template +inline constexpr bool has_make_from_tuple_impl, + std::void_t( + std::declval(), std::make_index_sequence>>{}))>> = true; // Test std::make_from_tuple. From 7c99e8b93f35336c3a3bb946e38df2feecff53e7 Mon Sep 17 00:00:00 2001 From: "Stephan T. Lavavej" Date: Tue, 26 Mar 2024 06:46:17 -0700 Subject: [PATCH 15/28] Rename `_Ugly` identifiers: `_Indices` => `Indices` --- .../LWG3528_make_from_tuple_impl/test.compile.pass.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/std/tests/LWG3528_make_from_tuple_impl/test.compile.pass.cpp b/tests/std/tests/LWG3528_make_from_tuple_impl/test.compile.pass.cpp index 45c4db515b5..cdceeaf705b 100644 --- a/tests/std/tests/LWG3528_make_from_tuple_impl/test.compile.pass.cpp +++ b/tests/std/tests/LWG3528_make_from_tuple_impl/test.compile.pass.cpp @@ -69,16 +69,16 @@ template >>, class = void> inline constexpr bool has_make_from_tuple = false; -template -inline constexpr bool has_make_from_tuple, +template +inline constexpr bool has_make_from_tuple, std::void_t(std::declval()))>> = true; template >>, class = void> inline constexpr bool has_make_from_tuple_impl = false; -template -inline constexpr bool has_make_from_tuple_impl, +template +inline constexpr bool has_make_from_tuple_impl, std::void_t( std::declval(), std::make_index_sequence>>{}))>> = true; From a5b121a8bdd0e91be8a82269f125c1155e401b58 Mon Sep 17 00:00:00 2001 From: "Stephan T. Lavavej" Date: Tue, 26 Mar 2024 06:46:56 -0700 Subject: [PATCH 16/28] Rename `_Ugly` identifiers: `_Seq` => `Seq` --- .../LWG3528_make_from_tuple_impl/test.compile.pass.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/std/tests/LWG3528_make_from_tuple_impl/test.compile.pass.cpp b/tests/std/tests/LWG3528_make_from_tuple_impl/test.compile.pass.cpp index cdceeaf705b..0954cb992f0 100644 --- a/tests/std/tests/LWG3528_make_from_tuple_impl/test.compile.pass.cpp +++ b/tests/std/tests/LWG3528_make_from_tuple_impl/test.compile.pass.cpp @@ -65,16 +65,16 @@ inline constexpr bool has_make_from_tuple_impl_sfinae = std::is_same_v(std::declval(), std::declval())), std::uint8_t>; -template >>, class = void> +template >>, + class = void> inline constexpr bool has_make_from_tuple = false; template inline constexpr bool has_make_from_tuple, std::void_t(std::declval()))>> = true; -template >>, class = void> +template >>, + class = void> inline constexpr bool has_make_from_tuple_impl = false; template From fd217a5b1afbcdc51639d8a097487fb4f0a6cca5 Mon Sep 17 00:00:00 2001 From: "Stephan T. Lavavej" Date: Tue, 26 Mar 2024 06:49:03 -0700 Subject: [PATCH 17/28] Nitpick: `struct` inheritance is already `public` by default. --- .../tests/LWG3528_make_from_tuple_impl/test.compile.pass.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/std/tests/LWG3528_make_from_tuple_impl/test.compile.pass.cpp b/tests/std/tests/LWG3528_make_from_tuple_impl/test.compile.pass.cpp index 0954cb992f0..d419866f2d1 100644 --- a/tests/std/tests/LWG3528_make_from_tuple_impl/test.compile.pass.cpp +++ b/tests/std/tests/LWG3528_make_from_tuple_impl/test.compile.pass.cpp @@ -22,7 +22,7 @@ struct A { int a; }; -struct B : public A {}; +struct B : A {}; struct C { C(const B&) {} From 1d9bdad1dcfd10647c08613dbce3f2b76ab1077a Mon Sep 17 00:00:00 2001 From: "Stephan T. Lavavej" Date: Tue, 26 Mar 2024 06:56:26 -0700 Subject: [PATCH 18/28] Avoid potentially-confusing `&&` in comments. --- .../test.compile.pass.cpp | 48 +++++++++---------- 1 file changed, 24 insertions(+), 24 deletions(-) diff --git a/tests/std/tests/LWG3528_make_from_tuple_impl/test.compile.pass.cpp b/tests/std/tests/LWG3528_make_from_tuple_impl/test.compile.pass.cpp index d419866f2d1..5b796987d74 100644 --- a/tests/std/tests/LWG3528_make_from_tuple_impl/test.compile.pass.cpp +++ b/tests/std/tests/LWG3528_make_from_tuple_impl/test.compile.pass.cpp @@ -84,23 +84,23 @@ inline constexpr bool has_make_from_tuple_impl && partial specialization +// reinterpret_cast, std::tuple, partial specialization static_assert(!has_make_from_tuple>); static_assert(has_make_from_tuple>); -// reinterpret_cast && std::array && partial specialization +// reinterpret_cast, std::array, partial specialization static_assert(!has_make_from_tuple>); static_assert(has_make_from_tuple>); -// reinterpret_cast && std::tuple && SFINAE +// reinterpret_cast, std::tuple, SFINAE static_assert(!has_make_from_tuple_sfinae>); static_assert(has_make_from_tuple_sfinae>); -// reinterpret_cast && std::array && SFINAE +// reinterpret_cast, std::array, SFINAE static_assert(!has_make_from_tuple_sfinae>); static_assert(has_make_from_tuple_sfinae>); -// const_cast && std::tuple && partial specialization +// const_cast, std::tuple, partial specialization static_assert(!has_make_from_tuple>); static_assert(!has_make_from_tuple>); static_assert(has_make_from_tuple>); @@ -108,7 +108,7 @@ static_assert(has_make_from_tuple>); static_assert(has_make_from_tuple>); static_assert(has_make_from_tuple>); -// const_cast && std::array && partial specialization +// const_cast, std::array, partial specialization static_assert(!has_make_from_tuple>); static_assert(!has_make_from_tuple>); static_assert(has_make_from_tuple>); @@ -116,7 +116,7 @@ static_assert(has_make_from_tuple>); static_assert(has_make_from_tuple>); static_assert(has_make_from_tuple>); -// const_cast && std::tuple && SFINAE +// const_cast, std::tuple, SFINAE static_assert(!has_make_from_tuple_sfinae>); static_assert(!has_make_from_tuple_sfinae>); static_assert(has_make_from_tuple_sfinae>); @@ -124,7 +124,7 @@ static_assert(has_make_from_tuple_sfinae>); static_assert(has_make_from_tuple_sfinae>); static_assert(has_make_from_tuple_sfinae>); -// const_cast && std::array && SFINAE +// const_cast, std::array, SFINAE static_assert(!has_make_from_tuple_sfinae>); static_assert(!has_make_from_tuple_sfinae>); static_assert(has_make_from_tuple_sfinae>); @@ -132,28 +132,28 @@ static_assert(has_make_from_tuple_sfinae>); static_assert(has_make_from_tuple_sfinae>); static_assert(has_make_from_tuple_sfinae>); -// static_cast && std::tuple && partial specialization +// static_cast, std::tuple, partial specialization static_assert(!has_make_from_tuple>); static_assert(!has_make_from_tuple>); static_assert(has_make_from_tuple>); static_assert(has_make_from_tuple>); static_assert(has_make_from_tuple>); -// static_cast && std::array && partial specialization +// static_cast, std::array, partial specialization static_assert(!has_make_from_tuple>); static_assert(!has_make_from_tuple>); static_assert(has_make_from_tuple>); static_assert(has_make_from_tuple>); static_assert(has_make_from_tuple>); -// static_cast && std::tuple && SFINAE +// static_cast, std::tuple, SFINAE static_assert(!has_make_from_tuple_sfinae>); static_assert(!has_make_from_tuple_sfinae>); static_assert(has_make_from_tuple_sfinae>); static_assert(has_make_from_tuple_sfinae>); static_assert(has_make_from_tuple_sfinae>); -// static_cast && std::array && SFINAE +// static_cast, std::array, SFINAE static_assert(!has_make_from_tuple_sfinae>); static_assert(!has_make_from_tuple_sfinae>); static_assert(has_make_from_tuple_sfinae>); @@ -162,23 +162,23 @@ static_assert(has_make_from_tuple_sfinae>); // Test std::__Make_from_tuple_impl. -// reinterpret_cast && std::tuple && partial specialization +// reinterpret_cast, std::tuple, partial specialization static_assert(!has_make_from_tuple_impl>); static_assert(has_make_from_tuple_impl>); -// reinterpret_cast && std::array && partial specialization +// reinterpret_cast, std::array, partial specialization static_assert(!has_make_from_tuple_impl>); static_assert(has_make_from_tuple_impl>); -// reinterpret_cast && std::tuple && SFINAE +// reinterpret_cast, std::tuple, SFINAE static_assert(!has_make_from_tuple_impl_sfinae>); static_assert(has_make_from_tuple_impl_sfinae>); -// reinterpret_cast && std::array && SFINAE +// reinterpret_cast, std::array, SFINAE static_assert(!has_make_from_tuple_impl_sfinae>); static_assert(has_make_from_tuple_impl_sfinae>); -// const_cast && std::tuple && partial specialization +// const_cast, std::tuple, partial specialization static_assert(!has_make_from_tuple_impl>); static_assert(!has_make_from_tuple_impl>); static_assert(has_make_from_tuple_impl>); @@ -186,7 +186,7 @@ static_assert(has_make_from_tuple_impl>); static_assert(has_make_from_tuple_impl>); static_assert(has_make_from_tuple_impl>); -// const_cast && std::array && partial specialization +// const_cast, std::array, partial specialization static_assert(!has_make_from_tuple_impl>); static_assert(!has_make_from_tuple_impl>); static_assert(has_make_from_tuple_impl>); @@ -194,7 +194,7 @@ static_assert(has_make_from_tuple_impl>); static_assert(has_make_from_tuple_impl>); static_assert(has_make_from_tuple_impl>); -// const_cast && std::tuple && SFINAE +// const_cast, std::tuple, SFINAE static_assert(!has_make_from_tuple_impl_sfinae>); static_assert(!has_make_from_tuple_impl_sfinae>); static_assert(has_make_from_tuple_impl_sfinae>); @@ -202,7 +202,7 @@ static_assert(has_make_from_tuple_impl_sfinae>); static_assert(has_make_from_tuple_impl_sfinae>); static_assert(has_make_from_tuple_impl_sfinae>); -// const_cast && std::array && SFINAE +// const_cast, std::array, SFINAE static_assert(!has_make_from_tuple_impl_sfinae>); static_assert(!has_make_from_tuple_impl_sfinae>); static_assert(has_make_from_tuple_impl_sfinae>); @@ -210,28 +210,28 @@ static_assert(has_make_from_tuple_impl_sfinae>); static_assert(has_make_from_tuple_impl_sfinae>); static_assert(has_make_from_tuple_impl_sfinae>); -// static_cast && std::tuple && partial specialization +// static_cast, std::tuple, partial specialization static_assert(!has_make_from_tuple_impl>); static_assert(!has_make_from_tuple_impl>); static_assert(has_make_from_tuple_impl>); static_assert(has_make_from_tuple_impl>); static_assert(has_make_from_tuple_impl>); -// static_cast && std::array && partial specialization +// static_cast, std::array, partial specialization static_assert(!has_make_from_tuple_impl>); static_assert(!has_make_from_tuple_impl>); static_assert(has_make_from_tuple_impl>); static_assert(has_make_from_tuple_impl>); static_assert(has_make_from_tuple_impl>); -// static_cast && std::tuple && SFINAE +// static_cast, std::tuple, SFINAE static_assert(!has_make_from_tuple_impl_sfinae>); static_assert(!has_make_from_tuple_impl_sfinae>); static_assert(has_make_from_tuple_impl_sfinae>); static_assert(has_make_from_tuple_impl_sfinae>); static_assert(has_make_from_tuple_impl_sfinae>); -// static_cast && std::array && SFINAE +// static_cast, std::array, SFINAE static_assert(!has_make_from_tuple_impl_sfinae>); static_assert(!has_make_from_tuple_impl_sfinae>); static_assert(has_make_from_tuple_impl_sfinae>); From 48f81d636cad589c16bd8898a2faf1b73c4a6dfd Mon Sep 17 00:00:00 2001 From: "Stephan T. Lavavej" Date: Tue, 26 Mar 2024 07:00:02 -0700 Subject: [PATCH 19/28] Fix comment typo (extra underscore). --- .../tests/LWG3528_make_from_tuple_impl/test.compile.pass.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/std/tests/LWG3528_make_from_tuple_impl/test.compile.pass.cpp b/tests/std/tests/LWG3528_make_from_tuple_impl/test.compile.pass.cpp index 5b796987d74..7932242925b 100644 --- a/tests/std/tests/LWG3528_make_from_tuple_impl/test.compile.pass.cpp +++ b/tests/std/tests/LWG3528_make_from_tuple_impl/test.compile.pass.cpp @@ -160,7 +160,7 @@ static_assert(has_make_from_tuple_sfinae>); static_assert(has_make_from_tuple_sfinae>); static_assert(has_make_from_tuple_sfinae>); -// Test std::__Make_from_tuple_impl. +// Test std::_Make_from_tuple_impl. // reinterpret_cast, std::tuple, partial specialization static_assert(!has_make_from_tuple_impl>); From 9146dfb30760bb5dc13208ca4663fa23b72aabf6 Mon Sep 17 00:00:00 2001 From: "Stephan T. Lavavej" Date: Tue, 26 Mar 2024 07:03:44 -0700 Subject: [PATCH 20/28] `B` and `C` were unused. --- .../LWG3528_make_from_tuple_impl/test.compile.pass.cpp | 6 ------ 1 file changed, 6 deletions(-) diff --git a/tests/std/tests/LWG3528_make_from_tuple_impl/test.compile.pass.cpp b/tests/std/tests/LWG3528_make_from_tuple_impl/test.compile.pass.cpp index 7932242925b..ca927b5345d 100644 --- a/tests/std/tests/LWG3528_make_from_tuple_impl/test.compile.pass.cpp +++ b/tests/std/tests/LWG3528_make_from_tuple_impl/test.compile.pass.cpp @@ -22,12 +22,6 @@ struct A { int a; }; -struct B : A {}; - -struct C { - C(const B&) {} -}; - enum class D { one, two, From 920c5d620c669d3cbc22d4ceef07f230ec8b713f Mon Sep 17 00:00:00 2001 From: "Stephan T. Lavavej" Date: Tue, 26 Mar 2024 07:57:55 -0700 Subject: [PATCH 21/28] Drop old-style (function-based) SFINAE test coverage. Verified that this exactly duplicated the new-style (partial specialization) coverage. --- .../test.compile.pass.cpp | 108 ------------------ 1 file changed, 108 deletions(-) diff --git a/tests/std/tests/LWG3528_make_from_tuple_impl/test.compile.pass.cpp b/tests/std/tests/LWG3528_make_from_tuple_impl/test.compile.pass.cpp index ca927b5345d..81872f1e009 100644 --- a/tests/std/tests/LWG3528_make_from_tuple_impl/test.compile.pass.cpp +++ b/tests/std/tests/LWG3528_make_from_tuple_impl/test.compile.pass.cpp @@ -27,38 +27,6 @@ enum class D { two, }; -template -auto can_make_from_tuple(T&&, Tuple&& t) -> decltype(std::make_from_tuple(t), std::uint8_t{}) { - return 0; -} - -template -std::uint32_t can_make_from_tuple(...) { - return 0; -} - -template -inline constexpr bool has_make_from_tuple_sfinae = - std::is_same_v(std::declval(), std::declval())), std::uint8_t>; - -template -auto can_make_from_tuple_impl(T&&, Tuple&& t) - -> decltype(std::_Make_from_tuple_impl(std::forward(t), - std::make_index_sequence>>{}), - std::uint8_t{}) { - return 0; -} - -template -std::uint32_t can_make_from_tuple_impl(...) { - return 0; -} - -template -inline constexpr bool has_make_from_tuple_impl_sfinae = - std::is_same_v(std::declval(), std::declval())), - std::uint8_t>; - template >>, class = void> inline constexpr bool has_make_from_tuple = false; @@ -86,14 +54,6 @@ static_assert(has_make_from_tuple>); static_assert(!has_make_from_tuple>); static_assert(has_make_from_tuple>); -// reinterpret_cast, std::tuple, SFINAE -static_assert(!has_make_from_tuple_sfinae>); -static_assert(has_make_from_tuple_sfinae>); - -// reinterpret_cast, std::array, SFINAE -static_assert(!has_make_from_tuple_sfinae>); -static_assert(has_make_from_tuple_sfinae>); - // const_cast, std::tuple, partial specialization static_assert(!has_make_from_tuple>); static_assert(!has_make_from_tuple>); @@ -110,22 +70,6 @@ static_assert(has_make_from_tuple>); static_assert(has_make_from_tuple>); static_assert(has_make_from_tuple>); -// const_cast, std::tuple, SFINAE -static_assert(!has_make_from_tuple_sfinae>); -static_assert(!has_make_from_tuple_sfinae>); -static_assert(has_make_from_tuple_sfinae>); -static_assert(has_make_from_tuple_sfinae>); -static_assert(has_make_from_tuple_sfinae>); -static_assert(has_make_from_tuple_sfinae>); - -// const_cast, std::array, SFINAE -static_assert(!has_make_from_tuple_sfinae>); -static_assert(!has_make_from_tuple_sfinae>); -static_assert(has_make_from_tuple_sfinae>); -static_assert(has_make_from_tuple_sfinae>); -static_assert(has_make_from_tuple_sfinae>); -static_assert(has_make_from_tuple_sfinae>); - // static_cast, std::tuple, partial specialization static_assert(!has_make_from_tuple>); static_assert(!has_make_from_tuple>); @@ -140,20 +84,6 @@ static_assert(has_make_from_tuple>); static_assert(has_make_from_tuple>); static_assert(has_make_from_tuple>); -// static_cast, std::tuple, SFINAE -static_assert(!has_make_from_tuple_sfinae>); -static_assert(!has_make_from_tuple_sfinae>); -static_assert(has_make_from_tuple_sfinae>); -static_assert(has_make_from_tuple_sfinae>); -static_assert(has_make_from_tuple_sfinae>); - -// static_cast, std::array, SFINAE -static_assert(!has_make_from_tuple_sfinae>); -static_assert(!has_make_from_tuple_sfinae>); -static_assert(has_make_from_tuple_sfinae>); -static_assert(has_make_from_tuple_sfinae>); -static_assert(has_make_from_tuple_sfinae>); - // Test std::_Make_from_tuple_impl. // reinterpret_cast, std::tuple, partial specialization @@ -164,14 +94,6 @@ static_assert(has_make_from_tuple_impl>); static_assert(!has_make_from_tuple_impl>); static_assert(has_make_from_tuple_impl>); -// reinterpret_cast, std::tuple, SFINAE -static_assert(!has_make_from_tuple_impl_sfinae>); -static_assert(has_make_from_tuple_impl_sfinae>); - -// reinterpret_cast, std::array, SFINAE -static_assert(!has_make_from_tuple_impl_sfinae>); -static_assert(has_make_from_tuple_impl_sfinae>); - // const_cast, std::tuple, partial specialization static_assert(!has_make_from_tuple_impl>); static_assert(!has_make_from_tuple_impl>); @@ -188,22 +110,6 @@ static_assert(has_make_from_tuple_impl>); static_assert(has_make_from_tuple_impl>); static_assert(has_make_from_tuple_impl>); -// const_cast, std::tuple, SFINAE -static_assert(!has_make_from_tuple_impl_sfinae>); -static_assert(!has_make_from_tuple_impl_sfinae>); -static_assert(has_make_from_tuple_impl_sfinae>); -static_assert(has_make_from_tuple_impl_sfinae>); -static_assert(has_make_from_tuple_impl_sfinae>); -static_assert(has_make_from_tuple_impl_sfinae>); - -// const_cast, std::array, SFINAE -static_assert(!has_make_from_tuple_impl_sfinae>); -static_assert(!has_make_from_tuple_impl_sfinae>); -static_assert(has_make_from_tuple_impl_sfinae>); -static_assert(has_make_from_tuple_impl_sfinae>); -static_assert(has_make_from_tuple_impl_sfinae>); -static_assert(has_make_from_tuple_impl_sfinae>); - // static_cast, std::tuple, partial specialization static_assert(!has_make_from_tuple_impl>); static_assert(!has_make_from_tuple_impl>); @@ -217,17 +123,3 @@ static_assert(!has_make_from_tuple_impl>); static_assert(has_make_from_tuple_impl>); static_assert(has_make_from_tuple_impl>); static_assert(has_make_from_tuple_impl>); - -// static_cast, std::tuple, SFINAE -static_assert(!has_make_from_tuple_impl_sfinae>); -static_assert(!has_make_from_tuple_impl_sfinae>); -static_assert(has_make_from_tuple_impl_sfinae>); -static_assert(has_make_from_tuple_impl_sfinae>); -static_assert(has_make_from_tuple_impl_sfinae>); - -// static_cast, std::array, SFINAE -static_assert(!has_make_from_tuple_impl_sfinae>); -static_assert(!has_make_from_tuple_impl_sfinae>); -static_assert(has_make_from_tuple_impl_sfinae>); -static_assert(has_make_from_tuple_impl_sfinae>); -static_assert(has_make_from_tuple_impl_sfinae>); From 37b1319f8228bf969397f0fa2502279098739417 Mon Sep 17 00:00:00 2001 From: "Stephan T. Lavavej" Date: Tue, 26 Mar 2024 07:59:55 -0700 Subject: [PATCH 22/28] No longer need `` and "partial specialization" comments. --- .../test.compile.pass.cpp | 25 +++++++++---------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/tests/std/tests/LWG3528_make_from_tuple_impl/test.compile.pass.cpp b/tests/std/tests/LWG3528_make_from_tuple_impl/test.compile.pass.cpp index 81872f1e009..99af71918f2 100644 --- a/tests/std/tests/LWG3528_make_from_tuple_impl/test.compile.pass.cpp +++ b/tests/std/tests/LWG3528_make_from_tuple_impl/test.compile.pass.cpp @@ -13,7 +13,6 @@ // * std/utilities/tuple/tuple.tuple/tuple.apply/make_from_tuple.pass.cpp #include -#include #include #include #include @@ -46,15 +45,15 @@ inline constexpr bool has_make_from_tuple_impl, partial specialization +// reinterpret_cast, std::tuple static_assert(!has_make_from_tuple>); static_assert(has_make_from_tuple>); -// reinterpret_cast, std::array, partial specialization +// reinterpret_cast, std::array static_assert(!has_make_from_tuple>); static_assert(has_make_from_tuple>); -// const_cast, std::tuple, partial specialization +// const_cast, std::tuple static_assert(!has_make_from_tuple>); static_assert(!has_make_from_tuple>); static_assert(has_make_from_tuple>); @@ -62,7 +61,7 @@ static_assert(has_make_from_tuple>); static_assert(has_make_from_tuple>); static_assert(has_make_from_tuple>); -// const_cast, std::array, partial specialization +// const_cast, std::array static_assert(!has_make_from_tuple>); static_assert(!has_make_from_tuple>); static_assert(has_make_from_tuple>); @@ -70,14 +69,14 @@ static_assert(has_make_from_tuple>); static_assert(has_make_from_tuple>); static_assert(has_make_from_tuple>); -// static_cast, std::tuple, partial specialization +// static_cast, std::tuple static_assert(!has_make_from_tuple>); static_assert(!has_make_from_tuple>); static_assert(has_make_from_tuple>); static_assert(has_make_from_tuple>); static_assert(has_make_from_tuple>); -// static_cast, std::array, partial specialization +// static_cast, std::array static_assert(!has_make_from_tuple>); static_assert(!has_make_from_tuple>); static_assert(has_make_from_tuple>); @@ -86,15 +85,15 @@ static_assert(has_make_from_tuple>); // Test std::_Make_from_tuple_impl. -// reinterpret_cast, std::tuple, partial specialization +// reinterpret_cast, std::tuple static_assert(!has_make_from_tuple_impl>); static_assert(has_make_from_tuple_impl>); -// reinterpret_cast, std::array, partial specialization +// reinterpret_cast, std::array static_assert(!has_make_from_tuple_impl>); static_assert(has_make_from_tuple_impl>); -// const_cast, std::tuple, partial specialization +// const_cast, std::tuple static_assert(!has_make_from_tuple_impl>); static_assert(!has_make_from_tuple_impl>); static_assert(has_make_from_tuple_impl>); @@ -102,7 +101,7 @@ static_assert(has_make_from_tuple_impl>); static_assert(has_make_from_tuple_impl>); static_assert(has_make_from_tuple_impl>); -// const_cast, std::array, partial specialization +// const_cast, std::array static_assert(!has_make_from_tuple_impl>); static_assert(!has_make_from_tuple_impl>); static_assert(has_make_from_tuple_impl>); @@ -110,14 +109,14 @@ static_assert(has_make_from_tuple_impl>); static_assert(has_make_from_tuple_impl>); static_assert(has_make_from_tuple_impl>); -// static_cast, std::tuple, partial specialization +// static_cast, std::tuple static_assert(!has_make_from_tuple_impl>); static_assert(!has_make_from_tuple_impl>); static_assert(has_make_from_tuple_impl>); static_assert(has_make_from_tuple_impl>); static_assert(has_make_from_tuple_impl>); -// static_cast, std::array, partial specialization +// static_cast, std::array static_assert(!has_make_from_tuple_impl>); static_assert(!has_make_from_tuple_impl>); static_assert(has_make_from_tuple_impl>); From 55bd07c1b9c45b4d5cd72c8bce4ef505ab9f2915 Mon Sep 17 00:00:00 2001 From: "Stephan T. Lavavej" Date: Tue, 26 Mar 2024 08:06:33 -0700 Subject: [PATCH 23/28] `class Seq` and `size_t... Indices` were unused. --- .../test.compile.pass.cpp | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/tests/std/tests/LWG3528_make_from_tuple_impl/test.compile.pass.cpp b/tests/std/tests/LWG3528_make_from_tuple_impl/test.compile.pass.cpp index 99af71918f2..046da559036 100644 --- a/tests/std/tests/LWG3528_make_from_tuple_impl/test.compile.pass.cpp +++ b/tests/std/tests/LWG3528_make_from_tuple_impl/test.compile.pass.cpp @@ -26,20 +26,18 @@ enum class D { two, }; -template >>, - class = void> +template inline constexpr bool has_make_from_tuple = false; -template -inline constexpr bool has_make_from_tuple, - std::void_t(std::declval()))>> = true; +template +inline constexpr bool + has_make_from_tuple(std::declval()))>> = true; -template >>, - class = void> +template inline constexpr bool has_make_from_tuple_impl = false; -template -inline constexpr bool has_make_from_tuple_impl, +template +inline constexpr bool has_make_from_tuple_impl( std::declval(), std::make_index_sequence>>{}))>> = true; From 60c656461151d62f0f6e73542bbc780d9f74a6a6 Mon Sep 17 00:00:00 2001 From: "Stephan T. Lavavej" Date: Tue, 26 Mar 2024 08:31:17 -0700 Subject: [PATCH 24/28] Restructure `make_from_tuple` into 23/20/17 cases. Drop `_EXPORT_STD` for 17. Fix preprocessor comment. --- stl/inc/tuple | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/stl/inc/tuple b/stl/inc/tuple index 729ade8970e..f940e6a3817 100644 --- a/stl/inc/tuple +++ b/stl/inc/tuple @@ -1103,16 +1103,15 @@ constexpr _Ty _Make_from_tuple_impl( return _Ty(_STD get<_Indices>(_STD forward<_Tuple>(_Tpl))...); } -#if _HAS_CXX20 #if _HAS_CXX23 _EXPORT_STD template -#else // ^^^ _HAS_CXX23 / !_HAS_CXX23 vvv + requires _Can_make_from_tuple<_Ty, _Tuple> +#elif _HAS_CXX20 _EXPORT_STD template -#endif // ^^^ !_HAS_CXX23 ^^^ requires _Can_make_from_tuple<_Ty, _Tuple> #else // ^^^ _HAS_CXX20 / !_HAS_CXX20 vvv -_EXPORT_STD template , int> = 0> -#endif // ^^^ !_HAS_CXX23 ^^^ +template , int> = 0> +#endif // ^^^ !_HAS_CXX20 ^^^ _NODISCARD constexpr _Ty make_from_tuple(_Tuple&& _Tpl) noexcept(noexcept(_STD _Make_from_tuple_impl<_Ty>( _STD forward<_Tuple>(_Tpl), make_index_sequence>>{}))) /* strengthened */ { // construct _Ty from the elements of _Tpl From ba03dc9c3111850487ab8488e76724bfa5737c29 Mon Sep 17 00:00:00 2001 From: "Stephan T. Lavavej" Date: Tue, 26 Mar 2024 08:40:58 -0700 Subject: [PATCH 25/28] Use a default template argument for `_Make_from_tuple_impl`, instead of a default function argument. --- stl/inc/tuple | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/stl/inc/tuple b/stl/inc/tuple index f940e6a3817..b563e9dcd57 100644 --- a/stl/inc/tuple +++ b/stl/inc/tuple @@ -1095,9 +1095,8 @@ template requires _Can_make_from_tuple<_Ty, _Tuple> constexpr _Ty _Make_from_tuple_impl(_Tuple&& _Tpl, index_sequence<_Indices...>) #else // ^^^ _HAS_CXX20 / !_HAS_CXX20 vvv -template -constexpr _Ty _Make_from_tuple_impl( - _Tuple&& _Tpl, index_sequence<_Indices...>, enable_if_t<_Can_make_from_tuple<_Ty, _Tuple>, int> = 0) +template , int> = 0> +constexpr _Ty _Make_from_tuple_impl(_Tuple&& _Tpl, index_sequence<_Indices...>) #endif // ^^^ !_HAS_CXX20 ^^^ noexcept(is_nothrow_constructible_v<_Ty, decltype(_STD get<_Indices>(_STD forward<_Tuple>(_Tpl)))...>) { return _Ty(_STD get<_Indices>(_STD forward<_Tuple>(_Tpl))...); From b5b95a76da0582ccfaa7aa22b409105396d71a9a Mon Sep 17 00:00:00 2001 From: "Stephan T. Lavavej" Date: Tue, 26 Mar 2024 08:46:38 -0700 Subject: [PATCH 26/28] Restructure `_Make_from_tuple_impl` into 23/20/17 cases. --- stl/inc/tuple | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/stl/inc/tuple b/stl/inc/tuple index b563e9dcd57..834f1c4c3ac 100644 --- a/stl/inc/tuple +++ b/stl/inc/tuple @@ -1086,19 +1086,17 @@ template inline constexpr bool _Can_make_from_tuple<_Ty, _Tuple, index_sequence<_Indices...>, enable_if_t(_STD declval<_Tuple>()))...>>> = true; -#if _HAS_CXX20 #if _HAS_CXX23 template -#else // ^^^ _HAS_CXX23 / !_HAS_CXX23 vvv + requires _Can_make_from_tuple<_Ty, _Tuple> +#elif _HAS_CXX20 template -#endif // ^^^ !_HAS_CXX23 ^^^ requires _Can_make_from_tuple<_Ty, _Tuple> -constexpr _Ty _Make_from_tuple_impl(_Tuple&& _Tpl, index_sequence<_Indices...>) #else // ^^^ _HAS_CXX20 / !_HAS_CXX20 vvv template , int> = 0> -constexpr _Ty _Make_from_tuple_impl(_Tuple&& _Tpl, index_sequence<_Indices...>) #endif // ^^^ !_HAS_CXX20 ^^^ - noexcept(is_nothrow_constructible_v<_Ty, decltype(_STD get<_Indices>(_STD forward<_Tuple>(_Tpl)))...>) { +constexpr _Ty _Make_from_tuple_impl(_Tuple&& _Tpl, index_sequence<_Indices...>) noexcept( + is_nothrow_constructible_v<_Ty, decltype(_STD get<_Indices>(_STD forward<_Tuple>(_Tpl)))...>) { return _Ty(_STD get<_Indices>(_STD forward<_Tuple>(_Tpl))...); } From 4e20186b04521607a6d0db6877a7c6f846341e14 Mon Sep 17 00:00:00 2001 From: "Stephan T. Lavavej" Date: Tue, 26 Mar 2024 09:14:13 -0700 Subject: [PATCH 27/28] Drop ALL constraints on `_Make_from_tuple_impl`, then drop test coverage. --- stl/inc/tuple | 8 ---- .../test.compile.pass.cpp | 48 ------------------- 2 files changed, 56 deletions(-) diff --git a/stl/inc/tuple b/stl/inc/tuple index 834f1c4c3ac..1510838461f 100644 --- a/stl/inc/tuple +++ b/stl/inc/tuple @@ -1086,15 +1086,7 @@ template inline constexpr bool _Can_make_from_tuple<_Ty, _Tuple, index_sequence<_Indices...>, enable_if_t(_STD declval<_Tuple>()))...>>> = true; -#if _HAS_CXX23 -template - requires _Can_make_from_tuple<_Ty, _Tuple> -#elif _HAS_CXX20 template - requires _Can_make_from_tuple<_Ty, _Tuple> -#else // ^^^ _HAS_CXX20 / !_HAS_CXX20 vvv -template , int> = 0> -#endif // ^^^ !_HAS_CXX20 ^^^ constexpr _Ty _Make_from_tuple_impl(_Tuple&& _Tpl, index_sequence<_Indices...>) noexcept( is_nothrow_constructible_v<_Ty, decltype(_STD get<_Indices>(_STD forward<_Tuple>(_Tpl)))...>) { return _Ty(_STD get<_Indices>(_STD forward<_Tuple>(_Tpl))...); diff --git a/tests/std/tests/LWG3528_make_from_tuple_impl/test.compile.pass.cpp b/tests/std/tests/LWG3528_make_from_tuple_impl/test.compile.pass.cpp index 046da559036..0ca11479715 100644 --- a/tests/std/tests/LWG3528_make_from_tuple_impl/test.compile.pass.cpp +++ b/tests/std/tests/LWG3528_make_from_tuple_impl/test.compile.pass.cpp @@ -33,14 +33,6 @@ template inline constexpr bool has_make_from_tuple(std::declval()))>> = true; -template -inline constexpr bool has_make_from_tuple_impl = false; - -template -inline constexpr bool has_make_from_tuple_impl( - std::declval(), std::make_index_sequence>>{}))>> = true; - // Test std::make_from_tuple. // reinterpret_cast, std::tuple @@ -80,43 +72,3 @@ static_assert(!has_make_from_tuple>); static_assert(has_make_from_tuple>); static_assert(has_make_from_tuple>); static_assert(has_make_from_tuple>); - -// Test std::_Make_from_tuple_impl. - -// reinterpret_cast, std::tuple -static_assert(!has_make_from_tuple_impl>); -static_assert(has_make_from_tuple_impl>); - -// reinterpret_cast, std::array -static_assert(!has_make_from_tuple_impl>); -static_assert(has_make_from_tuple_impl>); - -// const_cast, std::tuple -static_assert(!has_make_from_tuple_impl>); -static_assert(!has_make_from_tuple_impl>); -static_assert(has_make_from_tuple_impl>); -static_assert(has_make_from_tuple_impl>); -static_assert(has_make_from_tuple_impl>); -static_assert(has_make_from_tuple_impl>); - -// const_cast, std::array -static_assert(!has_make_from_tuple_impl>); -static_assert(!has_make_from_tuple_impl>); -static_assert(has_make_from_tuple_impl>); -static_assert(has_make_from_tuple_impl>); -static_assert(has_make_from_tuple_impl>); -static_assert(has_make_from_tuple_impl>); - -// static_cast, std::tuple -static_assert(!has_make_from_tuple_impl>); -static_assert(!has_make_from_tuple_impl>); -static_assert(has_make_from_tuple_impl>); -static_assert(has_make_from_tuple_impl>); -static_assert(has_make_from_tuple_impl>); - -// static_cast, std::array -static_assert(!has_make_from_tuple_impl>); -static_assert(!has_make_from_tuple_impl>); -static_assert(has_make_from_tuple_impl>); -static_assert(has_make_from_tuple_impl>); -static_assert(has_make_from_tuple_impl>); From d05eddd9d8a7c9ef6ccc6baa3d3ff0b7b7841e88 Mon Sep 17 00:00:00 2001 From: "Stephan T. Lavavej" Date: Tue, 26 Mar 2024 09:23:24 -0700 Subject: [PATCH 28/28] Drop `enable_if_t` layer within `_Can_make_from_tuple`. --- stl/inc/tuple | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/stl/inc/tuple b/stl/inc/tuple index 1510838461f..66edcc20877 100644 --- a/stl/inc/tuple +++ b/stl/inc/tuple @@ -1079,12 +1079,11 @@ constexpr decltype(auto) apply(_Callable&& _Obj, _Tuple&& _Tpl) noexcept( make_index_sequence>>{}); } -template >>, - class = void> +template >>> inline constexpr bool _Can_make_from_tuple = false; template -inline constexpr bool _Can_make_from_tuple<_Ty, _Tuple, index_sequence<_Indices...>, - enable_if_t(_STD declval<_Tuple>()))...>>> = true; +inline constexpr bool _Can_make_from_tuple<_Ty, _Tuple, index_sequence<_Indices...>> = + is_constructible_v<_Ty, decltype(_STD get<_Indices>(_STD declval<_Tuple>()))...>; template constexpr _Ty _Make_from_tuple_impl(_Tuple&& _Tpl, index_sequence<_Indices...>) noexcept(