diff options
author | Eric Fiselier <eric@efcs.ca> | 2019-06-23 20:28:29 +0000 |
---|---|---|
committer | Eric Fiselier <eric@efcs.ca> | 2019-06-23 20:28:29 +0000 |
commit | 3359a17b3aef1effa494da3abe7f438f5bb184a7 (patch) | |
tree | f51ba30f6eb36434c187ea7d887682f8204b749b /libcxx/include/optional | |
parent | e2291f5af92920ab8f85057b0b1c83e3eae200d5 (diff) | |
download | bcm5719-llvm-3359a17b3aef1effa494da3abe7f438f5bb184a7.tar.gz bcm5719-llvm-3359a17b3aef1effa494da3abe7f438f5bb184a7.zip |
Apply new meta-programming traits throughout the library.
The new meta-programming primitives are lower cost than the old versions. This patch removes those old versions and switches libc++ to use the new ones.
llvm-svn: 364160
Diffstat (limited to 'libcxx/include/optional')
-rw-r--r-- | libcxx/include/optional | 101 |
1 files changed, 51 insertions, 50 deletions
diff --git a/libcxx/include/optional b/libcxx/include/optional index 1fc752e6ff1..2fad11ce419 100644 --- a/libcxx/include/optional +++ b/libcxx/include/optional @@ -618,16 +618,16 @@ private: } }; template <class _Up> - using _CheckOptionalArgsCtor = conditional_t< - !is_same_v<__uncvref_t<_Up>, in_place_t> && - !is_same_v<__uncvref_t<_Up>, optional>, + using _CheckOptionalArgsCtor = _If< + _IsNotSame<__uncvref_t<_Up>, in_place_t>::value && + _IsNotSame<__uncvref_t<_Up>, optional>::value, _CheckOptionalArgsConstructor, __check_tuple_constructor_fail >; template <class _QualUp> struct _CheckOptionalLikeConstructor { template <class _Up, class _Opt = optional<_Up>> - using __check_constructible_from_opt = __lazy_or< + using __check_constructible_from_opt = _Or< is_constructible<_Tp, _Opt&>, is_constructible<_Tp, _Opt const&>, is_constructible<_Tp, _Opt&&>, @@ -638,7 +638,7 @@ private: is_convertible<_Opt const&&, _Tp> >; template <class _Up, class _Opt = optional<_Up>> - using __check_assignable_from_opt = __lazy_or< + using __check_assignable_from_opt = _Or< is_assignable<_Tp&, _Opt&>, is_assignable<_Tp&, _Opt const&>, is_assignable<_Tp&, _Opt&&>, @@ -664,18 +664,18 @@ private: }; template <class _Up, class _QualUp> - using _CheckOptionalLikeCtor = conditional_t< - __lazy_and< - __lazy_not<is_same<_Up, _Tp>>, + using _CheckOptionalLikeCtor = _If< + _And< + _IsNotSame<_Up, _Tp>, is_constructible<_Tp, _QualUp> >::value, _CheckOptionalLikeConstructor<_QualUp>, __check_tuple_constructor_fail >; template <class _Up, class _QualUp> - using _CheckOptionalLikeAssign = conditional_t< - __lazy_and< - __lazy_not<is_same<_Up, _Tp>>, + using _CheckOptionalLikeAssign = _If< + _And< + _IsNotSame<_Up, _Tp>, is_constructible<_Tp, _QualUp>, is_assignable<_Tp&, _QualUp> >::value, @@ -689,10 +689,10 @@ public: _LIBCPP_INLINE_VISIBILITY constexpr optional(optional&&) = default; _LIBCPP_INLINE_VISIBILITY constexpr optional(nullopt_t) noexcept {} - template <class _InPlaceT, class... _Args, class = enable_if_t< - __lazy_and< - is_same<_InPlaceT, in_place_t>, - is_constructible<value_type, _Args...> + template <class _InPlaceT, class... _Args, class = _EnableIf< + _And< + _IsSame<_InPlaceT, in_place_t>, + is_constructible<value_type, _Args...> >::value > > @@ -700,21 +700,21 @@ public: constexpr explicit optional(_InPlaceT, _Args&&... __args) : __base(in_place, _VSTD::forward<_Args>(__args)...) {} - template <class _Up, class... _Args, class = enable_if_t< + template <class _Up, class... _Args, class = _EnableIf< is_constructible_v<value_type, initializer_list<_Up>&, _Args...>> > _LIBCPP_INLINE_VISIBILITY constexpr explicit optional(in_place_t, initializer_list<_Up> __il, _Args&&... __args) : __base(in_place, __il, _VSTD::forward<_Args>(__args)...) {} - template <class _Up = value_type, enable_if_t< + template <class _Up = value_type, _EnableIf< _CheckOptionalArgsCtor<_Up>::template __enable_implicit<_Up>() , int> = 0> _LIBCPP_INLINE_VISIBILITY constexpr optional(_Up&& __v) : __base(in_place, _VSTD::forward<_Up>(__v)) {} - template <class _Up, enable_if_t< + template <class _Up, _EnableIf< _CheckOptionalArgsCtor<_Up>::template __enable_explicit<_Up>() , int> = 0> _LIBCPP_INLINE_VISIBILITY @@ -722,7 +722,7 @@ public: : __base(in_place, _VSTD::forward<_Up>(__v)) {} // LWG2756: conditionally explicit conversion from const optional<_Up>& - template <class _Up, enable_if_t< + template <class _Up, _EnableIf< _CheckOptionalLikeCtor<_Up, _Up const&>::template __enable_implicit<_Up>() , int> = 0> _LIBCPP_INLINE_VISIBILITY @@ -730,7 +730,7 @@ public: { this->__construct_from(__v); } - template <class _Up, enable_if_t< + template <class _Up, _EnableIf< _CheckOptionalLikeCtor<_Up, _Up const&>::template __enable_explicit<_Up>() , int> = 0> _LIBCPP_INLINE_VISIBILITY @@ -740,7 +740,7 @@ public: } // LWG2756: conditionally explicit conversion from optional<_Up>&& - template <class _Up, enable_if_t< + template <class _Up, _EnableIf< _CheckOptionalLikeCtor<_Up, _Up &&>::template __enable_implicit<_Up>() , int> = 0> _LIBCPP_INLINE_VISIBILITY @@ -748,7 +748,7 @@ public: { this->__construct_from(_VSTD::move(__v)); } - template <class _Up, enable_if_t< + template <class _Up, _EnableIf< _CheckOptionalLikeCtor<_Up, _Up &&>::template __enable_explicit<_Up>() , int> = 0> _LIBCPP_INLINE_VISIBILITY @@ -769,11 +769,12 @@ public: // LWG2756 template <class _Up = value_type, - class = enable_if_t - <__lazy_and< - integral_constant<bool, - !is_same_v<__uncvref_t<_Up>, optional> && - !(is_same_v<_Up, value_type> && is_scalar_v<value_type>) + class = _EnableIf< + _And< + _IsNotSame<__uncvref_t<_Up>, optional>, + _Or< + _IsNotSame<_Up, value_type>, + _Not<is_scalar<value_type>> >, is_constructible<value_type, _Up>, is_assignable<value_type&, _Up> @@ -791,7 +792,7 @@ public: } // LWG2756 - template <class _Up, enable_if_t< + template <class _Up, _EnableIf< _CheckOptionalLikeAssign<_Up, _Up const&>::template __enable_assign<_Up>() , int> = 0> _LIBCPP_INLINE_VISIBILITY @@ -803,7 +804,7 @@ public: } // LWG2756 - template <class _Up, enable_if_t< + template <class _Up, _EnableIf< _CheckOptionalLikeCtor<_Up, _Up &&>::template __enable_assign<_Up>() , int> = 0> _LIBCPP_INLINE_VISIBILITY @@ -815,7 +816,7 @@ public: } template <class... _Args, - class = enable_if_t + class = _EnableIf < is_constructible_v<value_type, _Args...> > @@ -830,7 +831,7 @@ public: } template <class _Up, class... _Args, - class = enable_if_t + class = _EnableIf < is_constructible_v<value_type, initializer_list<_Up>&, _Args...> > @@ -1026,7 +1027,7 @@ template<class T> // Comparisons between optionals template <class _Tp, class _Up> _LIBCPP_INLINE_VISIBILITY constexpr -enable_if_t< +_EnableIf< is_convertible_v<decltype(_VSTD::declval<const _Tp&>() == _VSTD::declval<const _Up&>()), bool>, bool @@ -1042,7 +1043,7 @@ operator==(const optional<_Tp>& __x, const optional<_Up>& __y) template <class _Tp, class _Up> _LIBCPP_INLINE_VISIBILITY constexpr -enable_if_t< +_EnableIf< is_convertible_v<decltype(_VSTD::declval<const _Tp&>() != _VSTD::declval<const _Up&>()), bool>, bool @@ -1058,7 +1059,7 @@ operator!=(const optional<_Tp>& __x, const optional<_Up>& __y) template <class _Tp, class _Up> _LIBCPP_INLINE_VISIBILITY constexpr -enable_if_t< +_EnableIf< is_convertible_v<decltype(_VSTD::declval<const _Tp&>() < _VSTD::declval<const _Up&>()), bool>, bool @@ -1074,7 +1075,7 @@ operator<(const optional<_Tp>& __x, const optional<_Up>& __y) template <class _Tp, class _Up> _LIBCPP_INLINE_VISIBILITY constexpr -enable_if_t< +_EnableIf< is_convertible_v<decltype(_VSTD::declval<const _Tp&>() > _VSTD::declval<const _Up&>()), bool>, bool @@ -1090,7 +1091,7 @@ operator>(const optional<_Tp>& __x, const optional<_Up>& __y) template <class _Tp, class _Up> _LIBCPP_INLINE_VISIBILITY constexpr -enable_if_t< +_EnableIf< is_convertible_v<decltype(_VSTD::declval<const _Tp&>() <= _VSTD::declval<const _Up&>()), bool>, bool @@ -1106,7 +1107,7 @@ operator<=(const optional<_Tp>& __x, const optional<_Up>& __y) template <class _Tp, class _Up> _LIBCPP_INLINE_VISIBILITY constexpr -enable_if_t< +_EnableIf< is_convertible_v<decltype(_VSTD::declval<const _Tp&>() >= _VSTD::declval<const _Up&>()), bool>, bool @@ -1220,7 +1221,7 @@ operator>=(nullopt_t, const optional<_Tp>& __x) noexcept // Comparisons with T template <class _Tp, class _Up> _LIBCPP_INLINE_VISIBILITY constexpr -enable_if_t< +_EnableIf< is_convertible_v<decltype(_VSTD::declval<const _Tp&>() == _VSTD::declval<const _Up&>()), bool>, bool @@ -1232,7 +1233,7 @@ operator==(const optional<_Tp>& __x, const _Up& __v) template <class _Tp, class _Up> _LIBCPP_INLINE_VISIBILITY constexpr -enable_if_t< +_EnableIf< is_convertible_v<decltype(_VSTD::declval<const _Tp&>() == _VSTD::declval<const _Up&>()), bool>, bool @@ -1244,7 +1245,7 @@ operator==(const _Tp& __v, const optional<_Up>& __x) template <class _Tp, class _Up> _LIBCPP_INLINE_VISIBILITY constexpr -enable_if_t< +_EnableIf< is_convertible_v<decltype(_VSTD::declval<const _Tp&>() != _VSTD::declval<const _Up&>()), bool>, bool @@ -1256,7 +1257,7 @@ operator!=(const optional<_Tp>& __x, const _Up& __v) template <class _Tp, class _Up> _LIBCPP_INLINE_VISIBILITY constexpr -enable_if_t< +_EnableIf< is_convertible_v<decltype(_VSTD::declval<const _Tp&>() != _VSTD::declval<const _Up&>()), bool>, bool @@ -1268,7 +1269,7 @@ operator!=(const _Tp& __v, const optional<_Up>& __x) template <class _Tp, class _Up> _LIBCPP_INLINE_VISIBILITY constexpr -enable_if_t< +_EnableIf< is_convertible_v<decltype(_VSTD::declval<const _Tp&>() < _VSTD::declval<const _Up&>()), bool>, bool @@ -1280,7 +1281,7 @@ operator<(const optional<_Tp>& __x, const _Up& __v) template <class _Tp, class _Up> _LIBCPP_INLINE_VISIBILITY constexpr -enable_if_t< +_EnableIf< is_convertible_v<decltype(_VSTD::declval<const _Tp&>() < _VSTD::declval<const _Up&>()), bool>, bool @@ -1292,7 +1293,7 @@ operator<(const _Tp& __v, const optional<_Up>& __x) template <class _Tp, class _Up> _LIBCPP_INLINE_VISIBILITY constexpr -enable_if_t< +_EnableIf< is_convertible_v<decltype(_VSTD::declval<const _Tp&>() <= _VSTD::declval<const _Up&>()), bool>, bool @@ -1304,7 +1305,7 @@ operator<=(const optional<_Tp>& __x, const _Up& __v) template <class _Tp, class _Up> _LIBCPP_INLINE_VISIBILITY constexpr -enable_if_t< +_EnableIf< is_convertible_v<decltype(_VSTD::declval<const _Tp&>() <= _VSTD::declval<const _Up&>()), bool>, bool @@ -1316,7 +1317,7 @@ operator<=(const _Tp& __v, const optional<_Up>& __x) template <class _Tp, class _Up> _LIBCPP_INLINE_VISIBILITY constexpr -enable_if_t< +_EnableIf< is_convertible_v<decltype(_VSTD::declval<const _Tp&>() > _VSTD::declval<const _Up&>()), bool>, bool @@ -1328,7 +1329,7 @@ operator>(const optional<_Tp>& __x, const _Up& __v) template <class _Tp, class _Up> _LIBCPP_INLINE_VISIBILITY constexpr -enable_if_t< +_EnableIf< is_convertible_v<decltype(_VSTD::declval<const _Tp&>() > _VSTD::declval<const _Up&>()), bool>, bool @@ -1340,7 +1341,7 @@ operator>(const _Tp& __v, const optional<_Up>& __x) template <class _Tp, class _Up> _LIBCPP_INLINE_VISIBILITY constexpr -enable_if_t< +_EnableIf< is_convertible_v<decltype(_VSTD::declval<const _Tp&>() >= _VSTD::declval<const _Up&>()), bool>, bool @@ -1352,7 +1353,7 @@ operator>=(const optional<_Tp>& __x, const _Up& __v) template <class _Tp, class _Up> _LIBCPP_INLINE_VISIBILITY constexpr -enable_if_t< +_EnableIf< is_convertible_v<decltype(_VSTD::declval<const _Tp&>() >= _VSTD::declval<const _Up&>()), bool>, bool @@ -1365,7 +1366,7 @@ operator>=(const _Tp& __v, const optional<_Up>& __x) template <class _Tp> inline _LIBCPP_INLINE_VISIBILITY -enable_if_t< +_EnableIf< is_move_constructible_v<_Tp> && is_swappable_v<_Tp>, void > |