summaryrefslogtreecommitdiffstats
path: root/contrib/libc++/include/array
diff options
context:
space:
mode:
Diffstat (limited to 'contrib/libc++/include/array')
-rw-r--r--contrib/libc++/include/array18
1 files changed, 13 insertions, 5 deletions
diff --git a/contrib/libc++/include/array b/contrib/libc++/include/array
index 8866eaf..719286d 100644
--- a/contrib/libc++/include/array
+++ b/contrib/libc++/include/array
@@ -34,7 +34,7 @@ struct array
// No explicit construct/copy/destroy for aggregate type
void fill(const T& u);
- void swap(array& a) noexcept(noexcept(swap(declval<T&>(), declval<T&>())));
+ void swap(array& a) noexcept(is_nothrow_swappable_v<T>);
// iterators:
iterator begin() noexcept;
@@ -141,8 +141,15 @@ struct _LIBCPP_TYPE_VIS_ONLY array
_LIBCPP_INLINE_VISIBILITY void fill(const value_type& __u)
{_VSTD::fill_n(__elems_, _Size, __u);}
_LIBCPP_INLINE_VISIBILITY
- void swap(array& __a) _NOEXCEPT_(__is_nothrow_swappable<_Tp>::value)
- {_VSTD::swap_ranges(__elems_, __elems_ + _Size, __a.__elems_);}
+ void swap(array& __a) _NOEXCEPT_(_Size == 0 || __is_nothrow_swappable<_Tp>::value)
+ { __swap_dispatch((std::integral_constant<bool, _Size == 0>()), __a); }
+
+ _LIBCPP_INLINE_VISIBILITY
+ void __swap_dispatch(std::true_type, array&) {}
+
+ _LIBCPP_INLINE_VISIBILITY
+ void __swap_dispatch(std::false_type, array& __a)
+ { _VSTD::swap_ranges(__elems_, __elems_ + _Size, __a.__elems_);}
// iterators:
_LIBCPP_INLINE_VISIBILITY
@@ -276,11 +283,12 @@ template <class _Tp, size_t _Size>
inline _LIBCPP_INLINE_VISIBILITY
typename enable_if
<
+ _Size == 0 ||
__is_swappable<_Tp>::value,
void
>::type
-swap(const array<_Tp, _Size>& __x, const array<_Tp, _Size>& __y)
- _NOEXCEPT_(__is_nothrow_swappable<_Tp>::value)
+swap(array<_Tp, _Size>& __x, array<_Tp, _Size>& __y)
+ _NOEXCEPT_(noexcept(__x.swap(__y)))
{
__x.swap(__y);
}
OpenPOWER on IntegriCloud