noexcept for <utility>. This included a little repair on pair, and some noexcept workarounds.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@132186 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -1659,13 +1659,7 @@ move_backward(_BidirectionalIterator1 __first, _BidirectionalIterator1 __last,
|
|||||||
|
|
||||||
// iter_swap
|
// iter_swap
|
||||||
|
|
||||||
template <class _ForwardIterator1, class _ForwardIterator2>
|
// moved to <type_traits> for better swap / noexcept support
|
||||||
inline _LIBCPP_INLINE_VISIBILITY
|
|
||||||
void
|
|
||||||
iter_swap(_ForwardIterator1 __a, _ForwardIterator2 __b)
|
|
||||||
{
|
|
||||||
swap(*__a, *__b);
|
|
||||||
}
|
|
||||||
|
|
||||||
// transform
|
// transform
|
||||||
|
|
||||||
|
@@ -1296,7 +1296,7 @@ struct is_destructible
|
|||||||
template <class _Tp>
|
template <class _Tp>
|
||||||
inline _LIBCPP_INLINE_VISIBILITY
|
inline _LIBCPP_INLINE_VISIBILITY
|
||||||
typename remove_reference<_Tp>::type&&
|
typename remove_reference<_Tp>::type&&
|
||||||
move(_Tp&& __t)
|
move(_Tp&& __t) _NOEXCEPT
|
||||||
{
|
{
|
||||||
typedef typename remove_reference<_Tp>::type _Up;
|
typedef typename remove_reference<_Tp>::type _Up;
|
||||||
return static_cast<_Up&&>(__t);
|
return static_cast<_Up&&>(__t);
|
||||||
@@ -1305,7 +1305,7 @@ move(_Tp&& __t)
|
|||||||
template <class _Tp>
|
template <class _Tp>
|
||||||
inline _LIBCPP_INLINE_VISIBILITY
|
inline _LIBCPP_INLINE_VISIBILITY
|
||||||
_Tp&&
|
_Tp&&
|
||||||
forward(typename std::remove_reference<_Tp>::type& __t)
|
forward(typename std::remove_reference<_Tp>::type& __t) _NOEXCEPT
|
||||||
{
|
{
|
||||||
return static_cast<_Tp&&>(__t);
|
return static_cast<_Tp&&>(__t);
|
||||||
}
|
}
|
||||||
@@ -1313,7 +1313,7 @@ forward(typename std::remove_reference<_Tp>::type& __t)
|
|||||||
template <class _Tp>
|
template <class _Tp>
|
||||||
inline _LIBCPP_INLINE_VISIBILITY
|
inline _LIBCPP_INLINE_VISIBILITY
|
||||||
_Tp&&
|
_Tp&&
|
||||||
forward(typename std::remove_reference<_Tp>::type&& __t)
|
forward(typename std::remove_reference<_Tp>::type&& __t) _NOEXCEPT
|
||||||
{
|
{
|
||||||
static_assert(!std::is_lvalue_reference<_Tp>::value,
|
static_assert(!std::is_lvalue_reference<_Tp>::value,
|
||||||
"Can not forward an rvalue as an lvalue.");
|
"Can not forward an rvalue as an lvalue.");
|
||||||
@@ -3000,13 +3000,25 @@ struct __invoke_of
|
|||||||
template <class _Tp>
|
template <class _Tp>
|
||||||
inline _LIBCPP_INLINE_VISIBILITY
|
inline _LIBCPP_INLINE_VISIBILITY
|
||||||
void
|
void
|
||||||
swap(_Tp& __x, _Tp& __y)
|
swap(_Tp& __x, _Tp& __y) _NOEXCEPT_(is_nothrow_move_constructible<_Tp>::value &&
|
||||||
|
is_nothrow_move_assignable<_Tp>::value)
|
||||||
{
|
{
|
||||||
_Tp __t(_STD::move(__x));
|
_Tp __t(_STD::move(__x));
|
||||||
__x = _STD::move(__y);
|
__x = _STD::move(__y);
|
||||||
__y = _STD::move(__t);
|
__y = _STD::move(__t);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template <class _ForwardIterator1, class _ForwardIterator2>
|
||||||
|
inline _LIBCPP_INLINE_VISIBILITY
|
||||||
|
void
|
||||||
|
iter_swap(_ForwardIterator1 __a, _ForwardIterator2 __b)
|
||||||
|
// _NOEXCEPT_(_NOEXCEPT_(swap(*__a, *__b)))
|
||||||
|
_NOEXCEPT_(_NOEXCEPT_(swap(*_STD::declval<_ForwardIterator1>(),
|
||||||
|
*_STD::declval<_ForwardIterator2>())))
|
||||||
|
{
|
||||||
|
swap(*__a, *__b);
|
||||||
|
}
|
||||||
|
|
||||||
_LIBCPP_END_NAMESPACE_STD
|
_LIBCPP_END_NAMESPACE_STD
|
||||||
|
|
||||||
#endif // _LIBCPP_TYPE_TRAITS
|
#endif // _LIBCPP_TYPE_TRAITS
|
||||||
|
@@ -29,11 +29,19 @@ namespace rel_ops
|
|||||||
template<class T> bool operator>=(const T&, const T&);
|
template<class T> bool operator>=(const T&, const T&);
|
||||||
}
|
}
|
||||||
|
|
||||||
template<class T> void swap(T& a, T& b);
|
template<class T>
|
||||||
template <class T, size_t N> void swap(T (&a)[N], T (&b)[N]);
|
void
|
||||||
|
swap(T& a, T& b) noexcept(is_nothrow_move_constructible<T>::value &&
|
||||||
|
is_nothrow_move_assignable<T>::value);
|
||||||
|
|
||||||
template <class T, class U> T&& forward(U&&);
|
template <class T, size_t N>
|
||||||
template <class T> typename remove_reference<T>::type&& move(T&&);
|
void
|
||||||
|
swap(T (&a)[N], T (&b)[N]) noexcept(noexcept(swap(*a, *b)));
|
||||||
|
|
||||||
|
template <class T> T&& forward(typename remove_reference<T>::type& t) noexcept;
|
||||||
|
template <class T> T&& forward(typename remove_reference<T>::type&& t) noexcept;
|
||||||
|
|
||||||
|
template <class T> typename remove_reference<T>::type&& move(T&&) noexcept;
|
||||||
|
|
||||||
template <class T>
|
template <class T>
|
||||||
typename conditional
|
typename conditional
|
||||||
@@ -42,7 +50,7 @@ template <class T>
|
|||||||
const T&,
|
const T&,
|
||||||
T&&
|
T&&
|
||||||
>::type
|
>::type
|
||||||
move_if_noexcept(T& x);
|
move_if_noexcept(T& x) noexcept;
|
||||||
|
|
||||||
template <class T> typename add_rvalue_reference<T>::type declval() noexcept;
|
template <class T> typename add_rvalue_reference<T>::type declval() noexcept;
|
||||||
|
|
||||||
@@ -56,6 +64,7 @@ struct pair
|
|||||||
T2 second;
|
T2 second;
|
||||||
|
|
||||||
pair(const pair&) = default;
|
pair(const pair&) = default;
|
||||||
|
pair(pair&&) = default;
|
||||||
constexpr pair();
|
constexpr pair();
|
||||||
pair(const T1& x, const T2& y);
|
pair(const T1& x, const T2& y);
|
||||||
template <class U, class V> pair(U&& x, V&& y);
|
template <class U, class V> pair(U&& x, V&& y);
|
||||||
@@ -66,10 +75,12 @@ struct pair
|
|||||||
tuple<Args2...> second_args);
|
tuple<Args2...> second_args);
|
||||||
|
|
||||||
template <class U, class V> pair& operator=(const pair<U, V>& p);
|
template <class U, class V> pair& operator=(const pair<U, V>& p);
|
||||||
pair& operator=(pair&& p);
|
pair& operator=(pair&& p) noexcept(is_nothrow_move_assignable<T1>::value &&
|
||||||
|
is_nothrow_move_assignable<T2>::value);
|
||||||
template <class U, class V> pair& operator=(pair<U, V>&& p);
|
template <class U, class V> pair& operator=(pair<U, V>&& p);
|
||||||
|
|
||||||
void swap(pair& p);
|
void swap(pair& p) noexcept(noexcept(swap(first, p.first)) &&
|
||||||
|
noexcept(swap(second, p.second)));
|
||||||
};
|
};
|
||||||
|
|
||||||
template <class T1, class T2> bool operator==(const pair<T1,T2>&, const pair<T1,T2>&);
|
template <class T1, class T2> bool operator==(const pair<T1,T2>&, const pair<T1,T2>&);
|
||||||
@@ -80,7 +91,9 @@ template <class T1, class T2> bool operator>=(const pair<T1,T2>&, const pair<T1,
|
|||||||
template <class T1, class T2> bool operator<=(const pair<T1,T2>&, const pair<T1,T2>&);
|
template <class T1, class T2> bool operator<=(const pair<T1,T2>&, const pair<T1,T2>&);
|
||||||
|
|
||||||
template <class T1, class T2> pair<V1, V2> make_pair(T1&&, T2&&);
|
template <class T1, class T2> pair<V1, V2> make_pair(T1&&, T2&&);
|
||||||
template <class T1, class T2> void swap(pair<T1, T2>& x, pair<T1, T2>& y);
|
template <class T1, class T2>
|
||||||
|
void
|
||||||
|
swap(pair<T1, T2>& x, pair<T1, T2>& y) noexcept(noexcept(x.swap(y)));
|
||||||
|
|
||||||
struct piecewise_construct_t { };
|
struct piecewise_construct_t { };
|
||||||
constexpr piecewise_construct_t piecewise_construct = piecewise_construct_t();
|
constexpr piecewise_construct_t piecewise_construct = piecewise_construct_t();
|
||||||
@@ -94,15 +107,15 @@ template <class T1, class T2> struct tuple_element<1, std::pair<T1, T2> >;
|
|||||||
|
|
||||||
template<size_t I, class T1, class T2>
|
template<size_t I, class T1, class T2>
|
||||||
typename tuple_element<I, std::pair<T1, T2> >::type&
|
typename tuple_element<I, std::pair<T1, T2> >::type&
|
||||||
get(std::pair<T1, T2>&);
|
get(std::pair<T1, T2>&) noexcept;
|
||||||
|
|
||||||
template<size_t I, class T1, class T2>
|
template<size_t I, class T1, class T2>
|
||||||
const typename const tuple_element<I, std::pair<T1, T2> >::type&
|
const typename const tuple_element<I, std::pair<T1, T2> >::type&
|
||||||
get(const std::pair<T1, T2>&);
|
get(const std::pair<T1, T2>&) noexcept;
|
||||||
|
|
||||||
template<size_t I, class T1, class T2>
|
template<size_t I, class T1, class T2>
|
||||||
typename tuple_element<I, std::pair<T1, T2> >::type&&
|
typename tuple_element<I, std::pair<T1, T2> >::type&&
|
||||||
get(std::pair<T1, T2>&&);
|
get(std::pair<T1, T2>&&) noexcept;
|
||||||
|
|
||||||
} // std
|
} // std
|
||||||
|
|
||||||
@@ -169,6 +182,7 @@ template<class _Tp, size_t _N>
|
|||||||
inline _LIBCPP_INLINE_VISIBILITY
|
inline _LIBCPP_INLINE_VISIBILITY
|
||||||
void
|
void
|
||||||
swap(_Tp (&__a)[_N], _Tp (&__b)[_N])
|
swap(_Tp (&__a)[_N], _Tp (&__b)[_N])
|
||||||
|
_NOEXCEPT_(_NOEXCEPT_(swap(_STD::declval<_Tp&>(), _STD::declval<_Tp&>())))
|
||||||
{
|
{
|
||||||
_STD::swap_ranges(__a, __a + _N, __b);
|
_STD::swap_ranges(__a, __a + _N, __b);
|
||||||
}
|
}
|
||||||
@@ -185,7 +199,7 @@ typename conditional
|
|||||||
#else // _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
#else // _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
||||||
const _Tp&
|
const _Tp&
|
||||||
#endif
|
#endif
|
||||||
move_if_noexcept(_Tp& __x)
|
move_if_noexcept(_Tp& __x) _NOEXCEPT
|
||||||
{
|
{
|
||||||
return _STD::move(__x);
|
return _STD::move(__x);
|
||||||
}
|
}
|
||||||
@@ -194,9 +208,6 @@ struct _LIBCPP_VISIBLE piecewise_construct_t { };
|
|||||||
//constexpr
|
//constexpr
|
||||||
extern const piecewise_construct_t piecewise_construct;// = piecewise_construct_t();
|
extern const piecewise_construct_t piecewise_construct;// = piecewise_construct_t();
|
||||||
|
|
||||||
template <class _T1, class _T2> struct pair;
|
|
||||||
template <class _T1, class _T2> void swap(pair<_T1, _T2>&, pair<_T1, _T2>&);
|
|
||||||
|
|
||||||
template <class _T1, class _T2>
|
template <class _T1, class _T2>
|
||||||
struct _LIBCPP_VISIBLE pair
|
struct _LIBCPP_VISIBLE pair
|
||||||
{
|
{
|
||||||
@@ -206,6 +217,9 @@ struct _LIBCPP_VISIBLE pair
|
|||||||
_T1 first;
|
_T1 first;
|
||||||
_T2 second;
|
_T2 second;
|
||||||
|
|
||||||
|
// pair(const pair&) = default;
|
||||||
|
// pair(pair&&) = default;
|
||||||
|
|
||||||
_LIBCPP_INLINE_VISIBILITY pair() : first(), second() {}
|
_LIBCPP_INLINE_VISIBILITY pair() : first(), second() {}
|
||||||
|
|
||||||
_LIBCPP_INLINE_VISIBILITY pair(const _T1& __x, const _T2& __y)
|
_LIBCPP_INLINE_VISIBILITY pair(const _T1& __x, const _T2& __y)
|
||||||
@@ -218,6 +232,14 @@ struct _LIBCPP_VISIBLE pair
|
|||||||
is_convertible<_U2, _T2>::value>::type* = 0)
|
is_convertible<_U2, _T2>::value>::type* = 0)
|
||||||
: first(__p.first), second(__p.second) {}
|
: first(__p.first), second(__p.second) {}
|
||||||
|
|
||||||
|
_LIBCPP_INLINE_VISIBILITY
|
||||||
|
pair& operator=(const pair& __p)
|
||||||
|
{
|
||||||
|
first = __p.first;
|
||||||
|
second = __p.second;
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
||||||
|
|
||||||
template <class _U1, class _U2,
|
template <class _U1, class _U2,
|
||||||
@@ -237,6 +259,16 @@ struct _LIBCPP_VISIBLE pair
|
|||||||
: first(_STD::forward<_U1>(__p.first)),
|
: first(_STD::forward<_U1>(__p.first)),
|
||||||
second(_STD::forward<_U2>(__p.second)) {}
|
second(_STD::forward<_U2>(__p.second)) {}
|
||||||
|
|
||||||
|
_LIBCPP_INLINE_VISIBILITY
|
||||||
|
pair&
|
||||||
|
operator=(pair&& __p) _NOEXCEPT_(is_nothrow_move_assignable<first_type>::value &&
|
||||||
|
is_nothrow_move_assignable<second_type>::value)
|
||||||
|
{
|
||||||
|
first = _STD::forward<first_type>(__p.first);
|
||||||
|
second = _STD::forward<second_type>(__p.second);
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
#ifndef _LIBCPP_HAS_NO_VARIADICS
|
#ifndef _LIBCPP_HAS_NO_VARIADICS
|
||||||
|
|
||||||
template<class _Tuple,
|
template<class _Tuple,
|
||||||
@@ -277,7 +309,19 @@ struct _LIBCPP_VISIBLE pair
|
|||||||
#endif // _LIBCPP_HAS_NO_VARIADICS
|
#endif // _LIBCPP_HAS_NO_VARIADICS
|
||||||
|
|
||||||
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
||||||
void _LIBCPP_INLINE_VISIBILITY swap(pair& __p) {_STD::swap(*this, __p);}
|
_LIBCPP_INLINE_VISIBILITY
|
||||||
|
void
|
||||||
|
swap(pair& __p) _NOEXCEPT_(
|
||||||
|
// _NOEXCEPT_(_STD::iter_swap(&first, &__p.first)) &&
|
||||||
|
// _NOEXCEPT_(_STD::iter_swap(&second, &__p.second)))
|
||||||
|
_NOEXCEPT_(_STD::iter_swap(&_STD::declval<first_type&>(),
|
||||||
|
&_STD::declval<first_type&>())) &&
|
||||||
|
_NOEXCEPT_(_STD::iter_swap(&_STD::declval<second_type&>(),
|
||||||
|
&_STD::declval<second_type&>())))
|
||||||
|
{
|
||||||
|
_STD::iter_swap(&first, &__p.first);
|
||||||
|
_STD::iter_swap(&second, &__p.second);
|
||||||
|
}
|
||||||
private:
|
private:
|
||||||
|
|
||||||
#ifndef _LIBCPP_HAS_NO_VARIADICS
|
#ifndef _LIBCPP_HAS_NO_VARIADICS
|
||||||
@@ -341,9 +385,10 @@ template <class _T1, class _T2>
|
|||||||
inline _LIBCPP_INLINE_VISIBILITY
|
inline _LIBCPP_INLINE_VISIBILITY
|
||||||
void
|
void
|
||||||
swap(pair<_T1, _T2>& __x, pair<_T1, _T2>& __y)
|
swap(pair<_T1, _T2>& __x, pair<_T1, _T2>& __y)
|
||||||
|
// _NOEXCEPT_(_NOEXCEPT_(__x.swap(__y)))
|
||||||
|
_NOEXCEPT_(_NOEXCEPT_((_STD::declval<pair<_T1, _T2>&>().swap(_STD::declval<pair<_T1, _T2>&>()))))
|
||||||
{
|
{
|
||||||
swap(__x.first, __y.first);
|
__x.swap(__y);
|
||||||
swap(__x.second, __y.second);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
||||||
|
Reference in New Issue
Block a user