Make pair/tuples assignment operators SFINAE properly.

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@276548 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Eric Fiselier
2016-07-24 05:51:11 +00:00
parent 678bf67dcf
commit 8b5233f11c
6 changed files with 312 additions and 7 deletions

View File

@@ -348,8 +348,15 @@ struct _LIBCPP_TYPE_VIS_ONLY pair
// Use the implicitly declared copy constructor in C++03
#endif
typedef typename remove_reference<_T1>::type _T1Unref;
typedef typename remove_reference<_T2>::type _T2Unref;
typedef integral_constant<bool,
is_copy_assignable<_T1>::value
&& is_copy_assignable<_T2>::value> _CanCopyAssign;
_LIBCPP_INLINE_VISIBILITY
pair& operator=(const pair& __p)
pair& operator=(typename conditional<_CanCopyAssign::value, pair, __nat>::type const& __p)
_NOEXCEPT_(is_nothrow_copy_assignable<first_type>::value &&
is_nothrow_copy_assignable<second_type>::value)
{
@@ -377,10 +384,15 @@ struct _LIBCPP_TYPE_VIS_ONLY pair
: first(_VSTD::forward<_U1>(__p.first)),
second(_VSTD::forward<_U2>(__p.second)) {}
typedef integral_constant<bool,
is_move_assignable<_T1>::value
&& is_move_assignable<_T2>::value> _CanMoveAssign;
_LIBCPP_INLINE_VISIBILITY
pair&
operator=(pair&& __p) _NOEXCEPT_(is_nothrow_move_assignable<first_type>::value &&
is_nothrow_move_assignable<second_type>::value)
operator=(typename conditional<_CanMoveAssign::value, pair, __nat>::type&& __p)
_NOEXCEPT_(is_nothrow_move_assignable<first_type>::value &&
is_nothrow_move_assignable<second_type>::value)
{
first = _VSTD::forward<first_type>(__p.first);
second = _VSTD::forward<second_type>(__p.second);
@@ -388,7 +400,6 @@ struct _LIBCPP_TYPE_VIS_ONLY pair
}
#ifndef _LIBCPP_HAS_NO_VARIADICS
template<class _Tuple,
class = typename enable_if<__tuple_convertible<_Tuple, pair>::value>::type>
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
@@ -411,7 +422,7 @@ struct _LIBCPP_TYPE_VIS_ONLY pair
{}
template <class _Tuple,
class = typename enable_if<__tuple_assignable<_Tuple, pair>::value>::type>
class = typename enable_if<!is_same<typename decay<_Tuple>::type, pair>::value && __tuple_assignable<_Tuple, pair>::value>::type>
_LIBCPP_INLINE_VISIBILITY
pair&
operator=(_Tuple&& __p)