From 5e1de27f680591a870d78e9952b23f76aed7f456 Mon Sep 17 00:00:00 2001 From: James Y Knight Date: Fri, 28 Jun 2024 08:42:55 -0500 Subject: [PATCH] Revert "[libc++][NFC] Simplify pair a bit" (#97003) Reverts llvm/llvm-project#96165 The change broke code like #include #include struct Test { std::vector> v; }; std::pair p; under `-std=c++20`, apparently by triggering certain template evaluations too eagerly. --- libcxx/include/__utility/pair.h | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/libcxx/include/__utility/pair.h b/libcxx/include/__utility/pair.h index 1b0d9241886f91..0afbebcdc9f2ae 100644 --- a/libcxx/include/__utility/pair.h +++ b/libcxx/include/__utility/pair.h @@ -16,6 +16,8 @@ #include <__fwd/array.h> #include <__fwd/pair.h> #include <__fwd/tuple.h> +#include <__tuple/sfinae_helpers.h> +#include <__tuple/tuple_element.h> #include <__tuple/tuple_indices.h> #include <__tuple/tuple_like_no_subrange.h> #include <__tuple/tuple_size.h> @@ -128,15 +130,19 @@ struct _LIBCPP_TEMPLATE_VIS pair } }; - template = 0> - explicit(!_CheckArgs::__enable_implicit_default()) _LIBCPP_HIDE_FROM_ABI constexpr pair() noexcept( + template + using _CheckArgsDep _LIBCPP_NODEBUG = + typename conditional< _MaybeEnable, _CheckArgs, __check_tuple_constructor_fail>::type; + + template ::__enable_default(), int> = 0> + explicit(!_CheckArgsDep<_Dummy>::__enable_implicit_default()) _LIBCPP_HIDE_FROM_ABI constexpr pair() noexcept( is_nothrow_default_constructible::value && is_nothrow_default_constructible::value) : first(), second() {} - template (), int> = 0> + template ::template __is_pair_constructible<_T1 const&, _T2 const&>(), int> = 0> _LIBCPP_HIDE_FROM_ABI - _LIBCPP_CONSTEXPR_SINCE_CXX14 explicit(!_CheckArgs::template __is_implicit<_T1 const&, _T2 const&>()) + _LIBCPP_CONSTEXPR_SINCE_CXX14 explicit(!_CheckArgsDep<_Dummy>::template __is_implicit<_T1 const&, _T2 const&>()) pair(_T1 const& __t1, _T2 const& __t2) noexcept(is_nothrow_copy_constructible::value && is_nothrow_copy_constructible::value) : first(__t1), second(__t2) {}