forked from OSchip/llvm-project
[libc++] Make __compressed_pair fully constexpr
Make `__compressed_pair` fully constexpr Reviewed By: ldionne, #libc, nilayvaish Spies: libcxx-commits Differential Revision: https://reviews.llvm.org/D115687
This commit is contained in:
parent
d5d8b1c972
commit
a376a3f354
|
@ -58,10 +58,8 @@ struct __compressed_pair_elem {
|
|||
: __value_(_VSTD::forward<_Args>(_VSTD::get<_Indexes>(__args))...) {}
|
||||
#endif
|
||||
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY reference __get() _NOEXCEPT { return __value_; }
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
const_reference __get() const _NOEXCEPT { return __value_; }
|
||||
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 reference __get() _NOEXCEPT { return __value_; }
|
||||
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR const_reference __get() const _NOEXCEPT { return __value_; }
|
||||
|
||||
private:
|
||||
_Tp __value_;
|
||||
|
@ -97,9 +95,8 @@ struct __compressed_pair_elem<_Tp, _Idx, true> : private _Tp {
|
|||
: __value_type(_VSTD::forward<_Args>(_VSTD::get<_Indexes>(__args))...) {}
|
||||
#endif
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY reference __get() _NOEXCEPT { return *this; }
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
const_reference __get() const _NOEXCEPT { return *this; }
|
||||
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 reference __get() _NOEXCEPT { return *this; }
|
||||
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR const_reference __get() const _NOEXCEPT { return *this; }
|
||||
};
|
||||
|
||||
template <class _T1, class _T2>
|
||||
|
@ -143,23 +140,19 @@ public:
|
|||
typename __make_tuple_indices<sizeof...(_Args2)>::type()) {}
|
||||
#endif
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
typename _Base1::reference first() _NOEXCEPT {
|
||||
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 typename _Base1::reference first() _NOEXCEPT {
|
||||
return static_cast<_Base1&>(*this).__get();
|
||||
}
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
typename _Base1::const_reference first() const _NOEXCEPT {
|
||||
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR typename _Base1::const_reference first() const _NOEXCEPT {
|
||||
return static_cast<_Base1 const&>(*this).__get();
|
||||
}
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
typename _Base2::reference second() _NOEXCEPT {
|
||||
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 typename _Base2::reference second() _NOEXCEPT {
|
||||
return static_cast<_Base2&>(*this).__get();
|
||||
}
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
typename _Base2::const_reference second() const _NOEXCEPT {
|
||||
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR typename _Base2::const_reference second() const _NOEXCEPT {
|
||||
return static_cast<_Base2 const&>(*this).__get();
|
||||
}
|
||||
|
||||
|
@ -172,11 +165,8 @@ public:
|
|||
return static_cast<_Base2*>(__pair);
|
||||
}
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
void swap(__compressed_pair& __x)
|
||||
_NOEXCEPT_(__is_nothrow_swappable<_T1>::value &&
|
||||
__is_nothrow_swappable<_T2>::value)
|
||||
{
|
||||
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 void swap(__compressed_pair& __x)
|
||||
_NOEXCEPT_(__is_nothrow_swappable<_T1>::value && __is_nothrow_swappable<_T2>::value) {
|
||||
using _VSTD::swap;
|
||||
swap(first(), __x.first());
|
||||
swap(second(), __x.second());
|
||||
|
@ -184,10 +174,9 @@ public:
|
|||
};
|
||||
|
||||
template <class _T1, class _T2>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
|
||||
void swap(__compressed_pair<_T1, _T2>& __x, __compressed_pair<_T1, _T2>& __y)
|
||||
_NOEXCEPT_(__is_nothrow_swappable<_T1>::value &&
|
||||
__is_nothrow_swappable<_T2>::value) {
|
||||
_NOEXCEPT_(__is_nothrow_swappable<_T1>::value && __is_nothrow_swappable<_T2>::value) {
|
||||
__x.swap(__y);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue