Skip to content

Commit 575d41e

Browse files
author
Howard Hinnant
committed
Correction to set of overloaded pair constructors for C++0x
llvm-svn: 130521
1 parent 29ba55c commit 575d41e

File tree

1 file changed

+15
-4
lines changed

1 file changed

+15
-4
lines changed

libcxx/include/utility

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,13 @@ struct _LIBCPP_VISIBLE pair
211211
_LIBCPP_INLINE_VISIBILITY pair(const _T1& __x, const _T2& __y)
212212
: first(__x), second(__y) {}
213213

214+
template<class _U1, class _U2>
215+
_LIBCPP_INLINE_VISIBILITY
216+
pair(const pair<_U1, _U2>& __p,
217+
typename enable_if<is_convertible<_U1, _T1>::value &&
218+
is_convertible<_U2, _T2>::value>::type* = 0)
219+
: first(__p.first), second(__p.second) {}
220+
214221
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
215222

216223
template <class _U1, class _U2,
@@ -222,6 +229,14 @@ struct _LIBCPP_VISIBLE pair
222229
second(_STD::forward<_U2>(__u2))
223230
{}
224231

232+
template<class _U1, class _U2>
233+
_LIBCPP_INLINE_VISIBILITY
234+
pair(pair<_U1, _U2>&& __p,
235+
typename enable_if<is_convertible<_U1, _T1>::value &&
236+
is_convertible<_U2, _T2>::value>::type* = 0)
237+
: first(_STD::forward<_U1>(__p.first)),
238+
second(_STD::forward<_U2>(__p.second)) {}
239+
225240
#ifndef _LIBCPP_HAS_NO_VARIADICS
226241

227242
template<class _Tuple,
@@ -261,10 +276,6 @@ struct _LIBCPP_VISIBLE pair
261276

262277
#endif // _LIBCPP_HAS_NO_VARIADICS
263278

264-
#else // _LIBCPP_HAS_NO_RVALUE_REFERENCES
265-
template<class _U1, class _U2>
266-
_LIBCPP_INLINE_VISIBILITY pair(const pair<_U1, _U2>& __p)
267-
: first(__p.first), second(__p.second) {}
268279
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
269280
void _LIBCPP_INLINE_VISIBILITY swap(pair& __p) {_STD::swap(*this, __p);}
270281
private:

0 commit comments

Comments
 (0)