@@ -49,6 +49,33 @@ _LIBCPP_PUSH_MACROS
49
49
50
50
_LIBCPP_BEGIN_NAMESPACE_STD
51
51
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
+
52
79
template <class , class >
53
80
struct __non_trivially_copyable_base {
54
81
_LIBCPP_CONSTEXPR _LIBCPP_HIDE_FROM_ABI __non_trivially_copyable_base () _NOEXCEPT {}
@@ -104,40 +131,16 @@ struct pair
104
131
return *this ;
105
132
}
106
133
#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 (
134
137
is_nothrow_default_constructible<first_type>::value && is_nothrow_default_constructible<second_type>::value)
135
138
: first(), second() {}
136
139
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 >
139
142
_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 &>())
141
144
pair(_T1 const & __t1, _T2 const & __t2) noexcept (is_nothrow_copy_constructible<first_type>::value &&
142
145
is_nothrow_copy_constructible<second_type>::value)
143
146
: first(__t1), second(__t2) {}
@@ -150,41 +153,52 @@ struct pair
150
153
class _U1 ,
151
154
class _U2 ,
152
155
# 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>())
155
159
pair(_U1&& __u1, _U2&& __u2) noexcept (is_nothrow_constructible<first_type, _U1>::value &&
156
160
is_nothrow_constructible<second_type, _U2>::value)
157
161
: first(std::forward<_U1>(__u1)), second(std::forward<_U2>(__u2)) {
158
162
}
159
163
160
164
# 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&>())
163
169
pair(pair<_U1, _U2>& __p) noexcept ((is_nothrow_constructible<first_type, _U1&>::value &&
164
170
is_nothrow_constructible<second_type, _U2&>::value))
165
171
: first(__p.first), second(__p.second) {}
166
172
# endif
167
173
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 &>())
173
181
pair(pair<_U1, _U2> const & __p) noexcept (is_nothrow_constructible<first_type, _U1 const &>::value &&
174
182
is_nothrow_constructible<second_type, _U2 const &>::value)
175
183
: first(__p.first), second(__p.second) {}
176
184
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>())
179
190
pair(pair<_U1, _U2>&& __p) noexcept (is_nothrow_constructible<first_type, _U1&&>::value &&
180
191
is_nothrow_constructible<second_type, _U2&&>::value)
181
192
: first(std::forward<_U1>(__p.first)), second(std::forward<_U2>(__p.second)) {}
182
193
183
194
# 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&&>())
188
202
pair(const pair<_U1, _U2>&& __p) noexcept (is_nothrow_constructible<first_type, const _U1&&>::value &&
189
203
is_nothrow_constructible<second_type, const _U2&&>::value)
190
204
: first(std::move(__p.first)), second(std::move(__p.second)) {}
0 commit comments