@@ -49,6 +49,33 @@ _LIBCPP_PUSH_MACROS
4949
5050_LIBCPP_BEGIN_NAMESPACE_STD
5151
52+ #ifndef _LIBCPP_CXX03_LANG
53+
54+ template <class _T1 , class _T2 >
55+ struct __check_pair_construction {
56+ template <int &...>
57+ static _LIBCPP_HIDE_FROM_ABI constexpr bool __enable_implicit_default () {
58+ return __is_implicitly_default_constructible<_T1>::value && __is_implicitly_default_constructible<_T2>::value;
59+ }
60+
61+ template <int &...>
62+ static _LIBCPP_HIDE_FROM_ABI constexpr bool __enable_default () {
63+ return is_default_constructible<_T1>::value && is_default_constructible<_T2>::value;
64+ }
65+
66+ template <class _U1 , class _U2 >
67+ static _LIBCPP_HIDE_FROM_ABI constexpr bool __is_pair_constructible () {
68+ return is_constructible<_T1, _U1>::value && is_constructible<_T2, _U2>::value;
69+ }
70+
71+ template <class _U1 , class _U2 >
72+ static _LIBCPP_HIDE_FROM_ABI constexpr bool __is_implicit () {
73+ return is_convertible<_U1, _T1>::value && is_convertible<_U2, _T2>::value;
74+ }
75+ };
76+
77+ #endif
78+
5279template <class , class >
5380struct __non_trivially_copyable_base {
5481 _LIBCPP_CONSTEXPR _LIBCPP_HIDE_FROM_ABI __non_trivially_copyable_base () _NOEXCEPT {}
@@ -104,40 +131,16 @@ struct _LIBCPP_TEMPLATE_VIS pair
104131 return *this ;
105132 }
106133#else
107- struct _CheckArgs {
108- template <int &...>
109- static _LIBCPP_HIDE_FROM_ABI constexpr bool __enable_implicit_default () {
110- return __is_implicitly_default_constructible<_T1>::value && __is_implicitly_default_constructible<_T2>::value;
111- }
112-
113- template <int &...>
114- static _LIBCPP_HIDE_FROM_ABI constexpr bool __enable_default () {
115- return is_default_constructible<_T1>::value && is_default_constructible<_T2>::value;
116- }
117-
118- template <class _U1 , class _U2 >
119- static _LIBCPP_HIDE_FROM_ABI constexpr bool __is_pair_constructible () {
120- return is_constructible<first_type, _U1>::value && is_constructible<second_type, _U2>::value;
121- }
122-
123- template <class _U1 , class _U2 >
124- static _LIBCPP_HIDE_FROM_ABI constexpr bool __is_implicit () {
125- return is_convertible<_U1, first_type>::value && is_convertible<_U2, second_type>::value;
126- }
127- };
128-
129- template <bool _MaybeEnable>
130- using _CheckArgsDep _LIBCPP_NODEBUG = __conditional_t <_MaybeEnable, _CheckArgs, void >;
131-
132- template <bool _Dummy = true , __enable_if_t <_CheckArgsDep<_Dummy>::__enable_default(), int > = 0 >
133- explicit (!_CheckArgsDep<_Dummy>::__enable_implicit_default()) _LIBCPP_HIDE_FROM_ABI constexpr pair() noexcept (
134+ template <class _CheckArgsDep = __check_pair_construction<_T1, _T2>,
135+ __enable_if_t <_CheckArgsDep::__enable_default(), int > = 0 >
136+ explicit (!_CheckArgsDep::__enable_implicit_default()) _LIBCPP_HIDE_FROM_ABI constexpr pair() noexcept (
134137 is_nothrow_default_constructible<first_type>::value && is_nothrow_default_constructible<second_type>::value)
135138 : first(), second() {}
136139
137- template <bool _Dummy = true ,
138- __enable_if_t <_CheckArgsDep<_Dummy> ::template __is_pair_constructible<_T1 const &, _T2 const &>(), int > = 0 >
140+ template <class _CheckArgsDep = __check_pair_construction<_T1, _T2> ,
141+ __enable_if_t <_CheckArgsDep::template __is_pair_constructible<_T1 const &, _T2 const &>(), int > = 0 >
139142 _LIBCPP_HIDE_FROM_ABI
140- _LIBCPP_CONSTEXPR_SINCE_CXX14 explicit (!_CheckArgsDep<_Dummy> ::template __is_implicit<_T1 const &, _T2 const &>())
143+ _LIBCPP_CONSTEXPR_SINCE_CXX14 explicit (!_CheckArgsDep::template __is_implicit<_T1 const &, _T2 const &>())
141144 pair(_T1 const & __t1, _T2 const & __t2) noexcept (is_nothrow_copy_constructible<first_type>::value &&
142145 is_nothrow_copy_constructible<second_type>::value)
143146 : first(__t1), second(__t2) {}
@@ -150,41 +153,52 @@ struct _LIBCPP_TEMPLATE_VIS pair
150153 class _U1 ,
151154 class _U2 ,
152155# endif
153- __enable_if_t <_CheckArgs::template __is_pair_constructible<_U1, _U2>(), int > = 0 >
154- _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 explicit (!_CheckArgs::template __is_implicit<_U1, _U2>())
156+ __enable_if_t <__check_pair_construction<_T1, _T2>::template __is_pair_constructible<_U1, _U2>(), int > = 0 >
157+ _LIBCPP_HIDE_FROM_ABI
158+ _LIBCPP_CONSTEXPR_SINCE_CXX14 explicit (!__check_pair_construction<_T1, _T2>::template __is_implicit<_U1, _U2>())
155159 pair(_U1&& __u1, _U2&& __u2) noexcept (is_nothrow_constructible<first_type, _U1>::value &&
156160 is_nothrow_constructible<second_type, _U2>::value)
157161 : first(std::forward<_U1>(__u1)), second(std::forward<_U2>(__u2)) {
158162 }
159163
160164# if _LIBCPP_STD_VER >= 23
161- template <class _U1 , class _U2 , __enable_if_t <_CheckArgs::template __is_pair_constructible<_U1&, _U2&>(), int > = 0 >
162- _LIBCPP_HIDE_FROM_ABI constexpr explicit (!_CheckArgs::template __is_implicit<_U1&, _U2&>())
165+ template <class _U1 ,
166+ class _U2 ,
167+ __enable_if_t <__check_pair_construction<_T1, _T2>::template __is_pair_constructible<_U1&, _U2&>(), int > = 0 >
168+ _LIBCPP_HIDE_FROM_ABI constexpr explicit (!__check_pair_construction<_T1, _T2>::template __is_implicit<_U1&, _U2&>())
163169 pair(pair<_U1, _U2>& __p) noexcept ((is_nothrow_constructible<first_type, _U1&>::value &&
164170 is_nothrow_constructible<second_type, _U2&>::value))
165171 : first(__p.first), second(__p.second) {}
166172# endif
167173
168- template <class _U1 ,
169- class _U2 ,
170- __enable_if_t <_CheckArgs::template __is_pair_constructible<_U1 const &, _U2 const &>(), int > = 0 >
171- _LIBCPP_HIDE_FROM_ABI
172- _LIBCPP_CONSTEXPR_SINCE_CXX14 explicit (!_CheckArgs::template __is_implicit<_U1 const &, _U2 const &>())
174+ template <
175+ class _U1 ,
176+ class _U2 ,
177+ __enable_if_t <__check_pair_construction<_T1, _T2>::template __is_pair_constructible<_U1 const &, _U2 const &>(),
178+ int > = 0 >
179+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 explicit (
180+ !__check_pair_construction<_T1, _T2>::template __is_implicit<_U1 const &, _U2 const &>())
173181 pair(pair<_U1, _U2> const & __p) noexcept (is_nothrow_constructible<first_type, _U1 const &>::value &&
174182 is_nothrow_constructible<second_type, _U2 const &>::value)
175183 : first(__p.first), second(__p.second) {}
176184
177- template <class _U1 , class _U2 , __enable_if_t <_CheckArgs::template __is_pair_constructible<_U1, _U2>(), int > = 0 >
178- _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 explicit (!_CheckArgs::template __is_implicit<_U1, _U2>())
185+ template <class _U1 ,
186+ class _U2 ,
187+ __enable_if_t <__check_pair_construction<_T1, _T2>::template __is_pair_constructible<_U1, _U2>(), int > = 0 >
188+ _LIBCPP_HIDE_FROM_ABI
189+ _LIBCPP_CONSTEXPR_SINCE_CXX14 explicit (!__check_pair_construction<_T1, _T2>::template __is_implicit<_U1, _U2>())
179190 pair(pair<_U1, _U2>&& __p) noexcept (is_nothrow_constructible<first_type, _U1&&>::value &&
180191 is_nothrow_constructible<second_type, _U2&&>::value)
181192 : first(std::forward<_U1>(__p.first)), second(std::forward<_U2>(__p.second)) {}
182193
183194# if _LIBCPP_STD_VER >= 23
184- template <class _U1 ,
185- class _U2 ,
186- __enable_if_t <_CheckArgs::template __is_pair_constructible<const _U1&&, const _U2&&>(), int > = 0 >
187- _LIBCPP_HIDE_FROM_ABI constexpr explicit (!_CheckArgs::template __is_implicit<const _U1&&, const _U2&&>())
195+ template <
196+ class _U1 ,
197+ class _U2 ,
198+ __enable_if_t <__check_pair_construction<_T1, _T2>::template __is_pair_constructible<const _U1&&, const _U2&&>(),
199+ int > = 0 >
200+ _LIBCPP_HIDE_FROM_ABI constexpr explicit (
201+ !__check_pair_construction<_T1, _T2>::template __is_implicit<const _U1&&, const _U2&&>())
188202 pair(const pair<_U1, _U2>&& __p) noexcept (is_nothrow_constructible<first_type, const _U1&&>::value &&
189203 is_nothrow_constructible<second_type, const _U2&&>::value)
190204 : first(std::move(__p.first)), second(std::move(__p.second)) {}
0 commit comments