summaryrefslogtreecommitdiffstats
path: root/libcxx/include/utility
diff options
context:
space:
mode:
authorEric Fiselier <eric@efcs.ca>2016-07-24 05:51:11 +0000
committerEric Fiselier <eric@efcs.ca>2016-07-24 05:51:11 +0000
commit904a5d700752b19fec363f4bf8d00d5eef2c7efd (patch)
treef7d6a75c823ad18809997cc06944305c5dfd04f7 /libcxx/include/utility
parent2e99ae4f97322372449697bf5266dc1e75fda48b (diff)
downloadbcm5719-llvm-904a5d700752b19fec363f4bf8d00d5eef2c7efd.tar.gz
bcm5719-llvm-904a5d700752b19fec363f4bf8d00d5eef2c7efd.zip
Make pair/tuples assignment operators SFINAE properly.
llvm-svn: 276548
Diffstat (limited to 'libcxx/include/utility')
-rw-r--r--libcxx/include/utility21
1 files changed, 16 insertions, 5 deletions
diff --git a/libcxx/include/utility b/libcxx/include/utility
index fd8a7f2fc52..74a28d8fd29 100644
--- a/libcxx/include/utility
+++ b/libcxx/include/utility
@@ -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)
OpenPOWER on IntegriCloud