]> gcc.gnu.org Git - gcc.git/commitdiff
libstdc++: Add std::__conditional_t alias template
authorJonathan Wakely <jwakely@redhat.com>
Thu, 6 May 2021 15:26:21 +0000 (16:26 +0100)
committerJonathan Wakely <jwakely@redhat.com>
Fri, 1 Oct 2021 19:34:49 +0000 (20:34 +0100)
This change is inspired by the suggestion in
http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2019/p1715r0.html

The new std::__conditional_t alias template is functionally equivalent
to std::conditional_t but should be more efficient to compile, due to
only ever instantiating two specializations (std::__conditional<true>
and std::__conditional<false>) rather than a new specialization for
every use of std::conditional.

The new alias template is also available in C++11, unlike the C++14
std::conditional_t alias.

Signed-off-by: Jonathan Wakely <jwakely@redhat.com>
libstdc++-v3/ChangeLog:

* include/std/type_traits (__conditional): New class template
for internal uses of std::conditional.
(__conditional_t): New alias template to replace conditional_t.
(__and_, __or_, __result_of_memfun, __result_of_memobj): Use
__conditional_t instead of conditional::type.
* include/bits/atomic_base.h (__atomic_impl::_Diff): Likewise.
* include/bits/hashtable.h (_Hashtable): Likewise.
* include/bits/hashtable_policy.h (_Node_iterator, _Insert_base)
(_Local_iterator): Likewise. Replace typedefs with
using-declarations.
* include/bits/move.h (move_if_noexcept): Use __conditional_t.
* include/bits/parse_numbers.h (_Select_int_base): Likewise.
* include/bits/ptr_traits.h (__make_not_void): Likewise.
* include/bits/ranges_algobase.h (__copy_or_move_backward)
(__copy_or_move): Likewise.
* include/bits/ranges_base.h (borrowed_iterator_t): Likewise.
* include/bits/ranges_util.h (borrowed_subrange_t): Likewise.
* include/bits/regex_compiler.h (_BracketMatcher): Use
__conditional_t. Replace typedefs with using-declarations.
* include/bits/shared_ptr_base.h (__shared_count): Use
__conditional_t.
* include/bits/stl_algobase.h (__copy_move, __copy_move_backward):
Likewise.
* include/bits/stl_iterator.h (__detail::__clamp_iter_cat)
(reverse_iterator::iterator_concept)
(__make_move_if_noexcept_iterator)
(iterator_traits<common_iterator<_It, _Sent>>)
(iterator_traits<counted_iterator<_It>>): Likewise.
* include/bits/stl_pair.h (_PCC, pair::operator=): Likewise.
* include/bits/stl_tree.h (_Rb_tree::insert_return_type)
(_Rb_tree::_M_clone_node): Likewise.
* include/bits/unique_ptr.h (unique_ptr(unique_ptr<U,E>&&)):
Likewise.
* include/bits/uses_allocator.h (__uses_alloc): Likewise.
(__is_uses_allocator_predicate): Likewise.
* include/debug/functions.h (__foreign_iterator_aux2): Likewise.
* include/experimental/any (any::_Manager, __any_caster):
Likewise.
* include/experimental/executor (async_completion): Likewise.
* include/experimental/functional (__boyer_moore_base_t):
Likewise.
* include/std/any (any::_Manager): Likewise.
* include/std/functional (__boyer_moore_base_t): Likewise.
* include/std/ranges (borrowed_iterator_t)
(borrowed_subrange_t, __detail::__maybe_present_t)
(__detail::__maybe_const_t, split_view): Likewise.
* include/std/tuple (__empty_not_final, tuple::operator=):
Likewise.
* include/std/variant (__detail::__variant::__get_t): Likewise.

27 files changed:
libstdc++-v3/include/bits/atomic_base.h
libstdc++-v3/include/bits/hashtable.h
libstdc++-v3/include/bits/hashtable_policy.h
libstdc++-v3/include/bits/move.h
libstdc++-v3/include/bits/parse_numbers.h
libstdc++-v3/include/bits/ptr_traits.h
libstdc++-v3/include/bits/ranges_algobase.h
libstdc++-v3/include/bits/ranges_base.h
libstdc++-v3/include/bits/ranges_util.h
libstdc++-v3/include/bits/regex_compiler.h
libstdc++-v3/include/bits/shared_ptr_base.h
libstdc++-v3/include/bits/stl_algobase.h
libstdc++-v3/include/bits/stl_iterator.h
libstdc++-v3/include/bits/stl_pair.h
libstdc++-v3/include/bits/stl_tree.h
libstdc++-v3/include/bits/unique_ptr.h
libstdc++-v3/include/bits/uses_allocator.h
libstdc++-v3/include/debug/functions.h
libstdc++-v3/include/experimental/any
libstdc++-v3/include/experimental/executor
libstdc++-v3/include/experimental/functional
libstdc++-v3/include/std/any
libstdc++-v3/include/std/functional
libstdc++-v3/include/std/ranges
libstdc++-v3/include/std/tuple
libstdc++-v3/include/std/type_traits
libstdc++-v3/include/std/variant

index 71e1de078b5f7d66ddc6db26a7d685839aceb471..9e18aadadafe3c167db75e5a14122371713dcdcf 100644 (file)
@@ -946,7 +946,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 
     // As above, but for difference_type arguments.
     template<typename _Tp>
-      using _Diff = conditional_t<is_pointer_v<_Tp>, ptrdiff_t, _Val<_Tp>>;
+      using _Diff = __conditional_t<is_pointer_v<_Tp>, ptrdiff_t, _Val<_Tp>>;
 
     template<size_t _Size, size_t _Align>
       _GLIBCXX_ALWAYS_INLINE bool
index 92516b81ae539356d63502e7226ea4ee2eb9c127..79a3096b62b6f4be2b06282b82269bc3f5f7a75f 100644 (file)
@@ -317,8 +317,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 
       template<typename _Ht>
        static constexpr
-       typename conditional<std::is_lvalue_reference<_Ht>::value,
-                            const value_type&, value_type&&>::type
+       __conditional_t<std::is_lvalue_reference<_Ht>::value,
+                       const value_type&, value_type&&>
        __fwd_value_for(value_type& __val) noexcept
        { return std::move(__val); }
 
@@ -875,10 +875,10 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
        _M_insert_unique(_Kt&&, _Arg&&, const _NodeGenerator&);
 
       template<typename _Kt>
-       static typename conditional<
+       static __conditional_t<
          __and_<__is_nothrow_invocable<_Hash&, const key_type&>,
                 __not_<__is_nothrow_invocable<_Hash&, _Kt>>>::value,
-         key_type, _Kt&&>::type
+         key_type, _Kt&&>
        _S_forward_key(_Kt&& __k)
        { return std::forward<_Kt>(__k); }
 
@@ -1540,9 +1540,9 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
        {
          __alloc_node_gen_t __alloc_gen(*this);
 
-         using _Fwd_Ht = typename
-           conditional<__move_if_noexcept_cond<value_type>::value,
-                       const _Hashtable&, _Hashtable&&>::type;
+         using _Fwd_Ht = __conditional_t<
+           __move_if_noexcept_cond<value_type>::value,
+           const _Hashtable&, _Hashtable&&>;
          _M_assign(std::forward<_Fwd_Ht>(__ht), __alloc_gen);
          __ht.clear();
        }
index 2130c958262a2f23b7b3d3ae75afc605040e5387..2f8502588f58abd90b0de6061ebaf0002cfbf7a6 100644 (file)
@@ -360,15 +360,15 @@ namespace __detail
       using __node_type = typename __base_type::__node_type;
 
     public:
-      typedef _Value                                   value_type;
-      typedef std::ptrdiff_t                           difference_type;
-      typedef std::forward_iterator_tag                        iterator_category;
+      using value_type = _Value;
+      using difference_type = std::ptrdiff_t;
+      using iterator_category = std::forward_iterator_tag;
 
-      using pointer = typename std::conditional<__constant_iterators,
-                                 const value_type*, value_type*>::type;
+      using pointer = __conditional_t<__constant_iterators,
+                                     const value_type*, value_type*>;
 
-      using reference = typename std::conditional<__constant_iterators,
-                                 const value_type&, value_type&>::type;
+      using reference = __conditional_t<__constant_iterators,
+                                       const value_type&, value_type&>;
 
       _Node_iterator() = default;
 
@@ -867,12 +867,13 @@ namespace __detail
       using iterator = _Node_iterator<_Value, __constant_iterators::value,
                                      __hash_cached::value>;
 
-      using const_iterator = _Node_const_iterator<_Value, __constant_iterators::value,
+      using const_iterator = _Node_const_iterator<_Value,
+                                                 __constant_iterators::value,
                                                  __hash_cached::value>;
 
-      using __ireturn_type = typename std::conditional<__unique_keys::value,
-                                                    std::pair<iterator, bool>,
-                                                    iterator>::type;
+      using __ireturn_type = __conditional_t<__unique_keys::value,
+                                            std::pair<iterator, bool>,
+                                            iterator>;
 
       __ireturn_type
       insert(const value_type& __v)
@@ -1482,15 +1483,13 @@ namespace __detail
       using __hash_code_base = typename __base_type::__hash_code_base;
 
     public:
-      typedef _Value                                   value_type;
-      typedef typename std::conditional<__constant_iterators,
-                                       const value_type*, value_type*>::type
-                                                       pointer;
-      typedef typename std::conditional<__constant_iterators,
-                                       const value_type&, value_type&>::type
-                                                       reference;
-      typedef std::ptrdiff_t                           difference_type;
-      typedef std::forward_iterator_tag                        iterator_category;
+      using value_type = _Value;
+      using pointer = __conditional_t<__constant_iterators,
+                                     const value_type*, value_type*>;
+      using reference = __conditional_t<__constant_iterators,
+                                       const value_type&, value_type&>;
+      using difference_type = ptrdiff_t;
+      using iterator_category = forward_iterator_tag;
 
       _Local_iterator() = default;
 
index 2dd7ed9e4f912f278f5e7d1e7139d5b972f7594f..1c13abc4da8901f33a07913901a301465d7adec2 100644 (file)
@@ -120,8 +120,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
    */
   template<typename _Tp>
     _GLIBCXX_NODISCARD
-    constexpr typename
-    conditional<__move_if_noexcept_cond<_Tp>::value, const _Tp&, _Tp&&>::type
+    constexpr
+    __conditional_t<__move_if_noexcept_cond<_Tp>::value, const _Tp&, _Tp&&>
     move_if_noexcept(_Tp& __x) noexcept
     { return std::move(__x); }
 
index 56186612f0f1284ee77daa9320ed6accbf591f99..54b63c0e2bb601b400c725a219cb21fffc3ad753 100644 (file)
@@ -266,9 +266,9 @@ namespace __select_int
 
   template<unsigned long long _Val, typename _IntType, typename... _Ints>
     struct _Select_int_base<_Val, _IntType, _Ints...>
-    : conditional_t<(_Val <= __gnu_cxx::__int_traits<_IntType>::__max),
-                   integral_constant<_IntType, (_IntType)_Val>,
-                   _Select_int_base<_Val, _Ints...>>
+    : __conditional_t<(_Val <= __gnu_cxx::__int_traits<_IntType>::__max),
+                     integral_constant<_IntType, (_IntType)_Val>,
+                     _Select_int_base<_Val, _Ints...>>
     { };
 
   template<unsigned long long _Val>
index 653a3580117af48a8acb513a1ab2cb06f65316f9..115b86d43e4fcb44aa11943594b26beac9b661b0 100644 (file)
@@ -73,7 +73,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 
   template<typename _Tp>
     using __make_not_void
-      = typename conditional<is_void<_Tp>::value, __undefined, _Tp>::type;
+      = __conditional_t<is_void<_Tp>::value, __undefined, _Tp>;
 
   /**
    * @brief  Uniform interface to all pointer-like types
index 78c295981d534886820b438634da03aab7ee00e3..cfbac839749d034b731af19a4832b80b03cfa79f 100644 (file)
@@ -195,9 +195,9 @@ namespace ranges
     requires (_IsMove
              ? indirectly_movable<_Iter, _Out>
              : indirectly_copyable<_Iter, _Out>)
-    constexpr conditional_t<_IsMove,
-                           move_backward_result<_Iter, _Out>,
-                           copy_backward_result<_Iter, _Out>>
+    constexpr __conditional_t<_IsMove,
+                             move_backward_result<_Iter, _Out>,
+                             copy_backward_result<_Iter, _Out>>
     __copy_or_move_backward(_Iter __first, _Sent __last, _Out __result);
 
   template<bool _IsMove,
@@ -206,9 +206,9 @@ namespace ranges
     requires (_IsMove
              ? indirectly_movable<_Iter, _Out>
              : indirectly_copyable<_Iter, _Out>)
-    constexpr conditional_t<_IsMove,
-                           move_result<_Iter, _Out>,
-                           copy_result<_Iter, _Out>>
+    constexpr __conditional_t<_IsMove,
+                             move_result<_Iter, _Out>,
+                             copy_result<_Iter, _Out>>
     __copy_or_move(_Iter __first, _Sent __last, _Out __result)
     {
       // TODO: implement more specializations to be at least on par with
@@ -349,9 +349,9 @@ namespace ranges
     requires (_IsMove
              ? indirectly_movable<_Iter, _Out>
              : indirectly_copyable<_Iter, _Out>)
-    constexpr conditional_t<_IsMove,
-                           move_backward_result<_Iter, _Out>,
-                           copy_backward_result<_Iter, _Out>>
+    constexpr __conditional_t<_IsMove,
+                             move_backward_result<_Iter, _Out>,
+                             copy_backward_result<_Iter, _Out>>
     __copy_or_move_backward(_Iter __first, _Sent __last, _Out __result)
     {
       // TODO: implement more specializations to be at least on par with
index 49c7d9c9f066371ee419f1d7d0361a0ee456619d..d6166ab1dd3cf96670ed275d608924f9bcf1fd8c 100644 (file)
@@ -907,9 +907,9 @@ namespace ranges
   };
 
   template<range _Range>
-    using borrowed_iterator_t = conditional_t<borrowed_range<_Range>,
-                                            iterator_t<_Range>,
-                                            dangling>;
+    using borrowed_iterator_t = __conditional_t<borrowed_range<_Range>,
+                                               iterator_t<_Range>,
+                                               dangling>;
 
 } // namespace ranges
 _GLIBCXX_END_NAMESPACE_VERSION
index 4e87cfc6ef1f9188276e7477be67fa25abe462ec..7e7b958d274481bd5f729c47beec7cae0e94c0bc 100644 (file)
@@ -418,9 +418,9 @@ namespace ranges
       enable_borrowed_range<subrange<_It, _Sent, _Kind>> = true;
 
   template<range _Range>
-    using borrowed_subrange_t = conditional_t<borrowed_range<_Range>,
-                                             subrange<iterator_t<_Range>>,
-                                             dangling>;
+    using borrowed_subrange_t = __conditional_t<borrowed_range<_Range>,
+                                               subrange<iterator_t<_Range>>,
+                                               dangling>;
 } // namespace ranges
 
 // The following ranges algorithms are used by <ranges>, and are defined here
index 62a49bf52cf89038da1a91d54419b378362496de..88c60c2bed74d592ff8b7ed81d1a82952e5bf812 100644 (file)
@@ -485,17 +485,17 @@ namespace __detail
 
     private:
       // Currently we only use the cache for char
-      typedef typename std::is_same<_CharT, char>::type _UseCache;
+      using _UseCache = typename std::is_same<_CharT, char>::type;
 
       static constexpr size_t
       _S_cache_size =
        1ul << (sizeof(_CharT) * __CHAR_BIT__ * int(_UseCache::value));
 
       struct _Dummy { };
-      typedef typename std::conditional<_UseCache::value,
-                                       std::bitset<_S_cache_size>,
-                                       _Dummy>::type _CacheT;
-      typedef typename std::make_unsigned<_CharT>::type _UnsignedCharT;
+      using _CacheT = std::__conditional_t<_UseCache::value,
+                                          std::bitset<_S_cache_size>,
+                                          _Dummy>;
+      using _UnsignedCharT = typename std::make_unsigned<_CharT>::type;
 
       bool
       _M_apply(_CharT __ch, false_type) const;
index 5be935d174d75a62a59c54a7f7de86bfb51626c1..3473a74280d7eadb9f63f323f141b951b439bd02 100644 (file)
@@ -675,9 +675,9 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
            return;
 
          using _Ptr = typename unique_ptr<_Tp, _Del>::pointer;
-         using _Del2 = typename conditional<is_reference<_Del>::value,
+         using _Del2 = __conditional_t<is_reference<_Del>::value,
              reference_wrapper<typename remove_reference<_Del>::type>,
-             _Del>::type;
+             _Del>;
          using _Sp_cd_type
            = _Sp_counted_deleter<_Ptr, _Del2, allocator<void>, _Lp>;
          using _Alloc = allocator<_Sp_cd_type>;
index e1443b8a92a6e3250ddbfc0ba222ce5411ade561..8627d59b589a7b92a0adf8f75ed685f9f73daf68 100644 (file)
@@ -420,11 +420,11 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
        __copy_m(const _Tp* __first, const _Tp* __last, _Tp* __result)
        {
 #if __cplusplus >= 201103L
-         using __assignable = conditional<_IsMove,
-                                          is_move_assignable<_Tp>,
-                                          is_copy_assignable<_Tp>>;
+         using __assignable = __conditional_t<_IsMove,
+                                              is_move_assignable<_Tp>,
+                                              is_copy_assignable<_Tp>>;
          // trivial types can have deleted assignment
-         static_assert( __assignable::type::value, "type must be assignable" );
+         static_assert( __assignable::value, "type must be assignable" );
 #endif
          const ptrdiff_t _Num = __last - __first;
          if (_Num)
@@ -731,11 +731,11 @@ _GLIBCXX_END_NAMESPACE_CONTAINER
        __copy_move_b(const _Tp* __first, const _Tp* __last, _Tp* __result)
        {
 #if __cplusplus >= 201103L
-         using __assignable = conditional<_IsMove,
-                                          is_move_assignable<_Tp>,
-                                          is_copy_assignable<_Tp>>;
+         using __assignable = __conditional_t<_IsMove,
+                                              is_move_assignable<_Tp>,
+                                              is_copy_assignable<_Tp>>;
          // trivial types can have deleted assignment
-         static_assert( __assignable::type::value, "type must be assignable" );
+         static_assert( __assignable::value, "type must be assignable" );
 #endif
          const ptrdiff_t _Num = __last - __first;
          if (_Num)
index df774eeb63ff71c7841fec91f4bda8fe33cf1e31..8afd67566134819778dcade08c3c9779e1483738 100644 (file)
@@ -100,7 +100,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
     // otherwise use _Otherwise.
     template<typename _Cat, typename _Limit, typename _Otherwise = _Cat>
       using __clamp_iter_cat
-       = conditional_t<derived_from<_Cat, _Limit>, _Limit, _Otherwise>;
+       = __conditional_t<derived_from<_Cat, _Limit>, _Limit, _Otherwise>;
   }
 #endif
 
@@ -155,9 +155,9 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
       typedef typename __traits_type::reference                reference;
 #else
       using iterator_concept
-       = conditional_t<random_access_iterator<_Iterator>,
-                       random_access_iterator_tag,
-                       bidirectional_iterator_tag>;
+       = __conditional_t<random_access_iterator<_Iterator>,
+                         random_access_iterator_tag,
+                         bidirectional_iterator_tag>;
       using iterator_category
        = __detail::__clamp_iter_cat<typename __traits_type::iterator_category,
                                     random_access_iterator_tag>;
@@ -1455,9 +1455,10 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
       typedef _Iterator                                        pointer;
       // _GLIBCXX_RESOLVE_LIB_DEFECTS
       // 2106. move_iterator wrapping iterators returning prvalues
-      typedef typename conditional<is_reference<__base_ref>::value,
-                        typename remove_reference<__base_ref>::type&&,
-                        __base_ref>::type              reference;
+      using reference
+       = __conditional_t<is_reference<__base_ref>::value,
+                         typename remove_reference<__base_ref>::type&&,
+                         __base_ref>;
 #endif
 
       _GLIBCXX17_CONSTEXPR
@@ -1762,9 +1763,9 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
     { return move_iterator<_Iterator>(std::move(__i)); }
 
   template<typename _Iterator, typename _ReturnType
-    = typename conditional<__move_if_noexcept_cond
+    = __conditional_t<__move_if_noexcept_cond
       <typename iterator_traits<_Iterator>::value_type>::value,
-                _Iterator, move_iterator<_Iterator>>::type>
+               _Iterator, move_iterator<_Iterator>>>
     inline _GLIBCXX17_CONSTEXPR _ReturnType
     __make_move_if_noexcept_iterator(_Iterator __i)
     { return _ReturnType(__i); }
@@ -1772,8 +1773,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
   // Overload for pointers that matches std::move_if_noexcept more closely,
   // returning a constant iterator when we don't want to move.
   template<typename _Tp, typename _ReturnType
-    = typename conditional<__move_if_noexcept_cond<_Tp>::value,
-                          const _Tp*, move_iterator<_Tp*>>::type>
+    = __conditional_t<__move_if_noexcept_cond<_Tp>::value,
+                     const _Tp*, move_iterator<_Tp*>>>
     inline _GLIBCXX17_CONSTEXPR _ReturnType
     __make_move_if_noexcept_iterator(_Tp* __i)
     { return _ReturnType(__i); }
@@ -2178,8 +2179,9 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
       }
 
     public:
-      using iterator_concept = conditional_t<forward_iterator<_It>,
-           forward_iterator_tag, input_iterator_tag>;
+      using iterator_concept = __conditional_t<forward_iterator<_It>,
+                                              forward_iterator_tag,
+                                              input_iterator_tag>;
       using iterator_category = decltype(_S_iter_cat());
       using value_type = iter_value_t<_It>;
       using difference_type = iter_difference_t<_It>;
@@ -2459,9 +2461,9 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
     requires same_as<__detail::__iter_traits<_It>, iterator_traits<_It>>
     struct iterator_traits<counted_iterator<_It>> : iterator_traits<_It>
     {
-      using pointer = conditional_t<contiguous_iterator<_It>,
-                                   add_pointer_t<iter_reference_t<_It>>,
-                                   void>;
+      using pointer = __conditional_t<contiguous_iterator<_It>,
+                                     add_pointer_t<iter_reference_t<_It>>,
+                                     void>;
     };
 #endif // C++20
 
index 329485ce3b29fbde9552ce254bb2901ca7185dca..5b400daf97f850517721c11937d24eec9bb5d77a 100644 (file)
@@ -129,15 +129,14 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
                      is_convertible<_U2&&, _T2>>::value;
       }
 
-
       template <bool __implicit, typename _U1, typename _U2>
       static constexpr bool _DeprConsPair()
       {
        using __do_converts = __and_<is_convertible<_U1&&, _T1>,
                                     is_convertible<_U2&&, _T2>>;
-       using __converts = typename conditional<__implicit,
-                                               __do_converts,
-                                               __not_<__do_converts>>::type;
+       using __converts = __conditional_t<__implicit,
+                                          __do_converts,
+                                          __not_<__do_converts>>;
        return __and_<is_constructible<_T1, _U1&&>,
                      is_constructible<_T2, _U2&&>,
                      __converts
@@ -561,10 +560,9 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
          second(std::forward<_U2>(__p.second)) { }
 
       pair&
-      operator=(typename conditional<
-               __and_<is_copy_assignable<_T1>,
-                      is_copy_assignable<_T2>>::value,
-               const pair&, const __nonesuch&>::type __p)
+      operator=(__conditional_t<__and_<is_copy_assignable<_T1>,
+                                      is_copy_assignable<_T2>>::value,
+                               const pair&, const __nonesuch&> __p)
       {
        first = __p.first;
        second = __p.second;
@@ -572,10 +570,9 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
       }
 
       pair&
-      operator=(typename conditional<
-               __and_<is_move_assignable<_T1>,
-                      is_move_assignable<_T2>>::value,
-               pair&&, __nonesuch&&>::type __p)
+      operator=(__conditional_t<__and_<is_move_assignable<_T1>,
+                                      is_move_assignable<_T2>>::value,
+                               pair&&, __nonesuch&&> __p)
       noexcept(__and_<is_nothrow_move_assignable<_T1>,
                      is_nothrow_move_assignable<_T2>>::value)
       {
index e4e3e0b985cf961ecc195f31768120c1cdc11353..0692525be57b538fefe7db037bb4f81eb7601bcd 100644 (file)
@@ -637,9 +637,9 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
        _M_clone_node(_Link_type __x, _NodeGen& __node_gen)
        {
 #if __cplusplus >= 201103L
-         using _Vp = typename conditional<_MoveValue,
-                                          value_type&&,
-                                          const value_type&>::type;
+         using _Vp = __conditional_t<_MoveValue,
+                                     value_type&&,
+                                     const value_type&>;
 #endif
          _Link_type __tmp
            = __node_gen(_GLIBCXX_FORWARD(_Vp, *__x->_M_valptr()));
@@ -821,7 +821,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 #if __cplusplus > 201402L
       using node_type = _Node_handle<_Key, _Val, _Node_allocator>;
       using insert_return_type = _Node_insert_return<
-       conditional_t<is_same_v<_Key, _Val>, const_iterator, iterator>,
+       __conditional_t<is_same_v<_Key, _Val>, const_iterator, iterator>,
        node_type>;
 #endif
 
index da582176e84df15459fe1a4e6920e7efb1a42f68..c257e9573e02c89e8908d57251d26d8cd68160c3 100644 (file)
@@ -338,9 +338,9 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
        */
       template<typename _Up, typename _Ep, typename = _Require<
                __safe_conversion_up<_Up, _Ep>,
-              typename conditional<is_reference<_Dp>::value,
-                                   is_same<_Ep, _Dp>,
-                                   is_convertible<_Ep, _Dp>>::type>>
+              __conditional_t<is_reference<_Dp>::value,
+                              is_same<_Ep, _Dp>,
+                              is_convertible<_Ep, _Dp>>>>
        unique_ptr(unique_ptr<_Up, _Ep>&& __u) noexcept
        : _M_t(__u.release(), std::forward<_Ep>(__u.get_deleter()))
        { }
@@ -605,9 +605,9 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 
       template<typename _Up, typename _Ep, typename = _Require<
               __safe_conversion_up<_Up, _Ep>,
-              typename conditional<is_reference<_Dp>::value,
-                                   is_same<_Ep, _Dp>,
-                                   is_convertible<_Ep, _Dp>>::type>>
+              __conditional_t<is_reference<_Dp>::value,
+                              is_same<_Ep, _Dp>,
+                              is_convertible<_Ep, _Dp>>>>
        unique_ptr(unique_ptr<_Up, _Ep>&& __u) noexcept
        : _M_t(__u.release(), std::forward<_Ep>(__u.get_deleter()))
        { }
index 36b219ccc59f8fe89022319605fa1756d97ed8a6..358c5713da5ca1fb622c1ffa785e9ecc7a2406db 100644 (file)
@@ -86,10 +86,10 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 
   template<typename _Tp, typename _Alloc, typename... _Args>
     struct __uses_alloc<true, _Tp, _Alloc, _Args...>
-    : conditional<
+    : __conditional_t<
         is_constructible<_Tp, allocator_arg_t, const _Alloc&, _Args...>::value,
         __uses_alloc1<_Alloc>,
-               __uses_alloc2<_Alloc>>::type
+               __uses_alloc2<_Alloc>>
     {
       // _GLIBCXX_RESOLVE_LIB_DEFECTS
       // 2586. Wrong value category used in scoped_allocator_adaptor::construct
@@ -131,10 +131,10 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
   template<template<typename...> class _Predicate,
           typename _Tp, typename _Alloc, typename... _Args>
     struct __is_uses_allocator_predicate
-    : conditional<uses_allocator<_Tp, _Alloc>::value,
+    : __conditional_t<uses_allocator<_Tp, _Alloc>::value,
       __or_<_Predicate<_Tp, allocator_arg_t, _Alloc, _Args...>,
            _Predicate<_Tp, _Args..., _Alloc>>,
-      _Predicate<_Tp, _Args...>>::type { };
+      _Predicate<_Tp, _Args...>> { };
 
   template<typename _Tp, typename _Alloc, typename... _Args>
     struct __is_uses_allocator_constructible
index 6cac11f2abd843d30cb47f860636321efaa73a27..5d5354410f3f51ffcb0c5eb040d384158dd8be79 100644 (file)
@@ -33,7 +33,7 @@
 
 #if __cplusplus >= 201103L
 # include <bits/stl_iterator.h>        // for __miter_base
-# include <type_traits>                // for is_lvalue_reference and conditional.
+# include <type_traits>                // for is_lvalue_reference and __conditional_t.
 #endif
 
 #include <debug/helper_functions.h>
@@ -158,8 +158,8 @@ namespace __gnu_debug
       using __lvalref = std::is_lvalue_reference<
        typename std::iterator_traits<_InputIterator>::reference>;
       using __contiguous = _Is_contiguous_sequence<_Sequence>;
-      using __tag = typename std::conditional<__lvalref::value, __contiguous,
-                                             std::__false_type>::type;
+      using __tag = std::__conditional_t<__lvalref::value, __contiguous,
+                                        std::__false_type>;
 #endif
       return __foreign_iterator_aux3(__it, __other, __other_end, __tag());
     }
index 7d18f267e8b53714529675916663f0a849192e2e..44f5db0fb87eac010eb532f5fcdc7d8f81f28812 100644 (file)
@@ -115,9 +115,9 @@ inline namespace fundamentals_v1
       struct _Manager_external; // creates contained object on the heap
 
     template<typename _Tp>
-      using _Manager = conditional_t<_Internal<_Tp>::value,
-                                    _Manager_internal<_Tp>,
-                                    _Manager_external<_Tp>>;
+      using _Manager = __conditional_t<_Internal<_Tp>::value,
+                                      _Manager_internal<_Tp>,
+                                      _Manager_external<_Tp>>;
 
     template<typename _Tp, typename _Decayed = decay_t<_Tp>>
       using _Decay = enable_if_t<!is_same<_Decayed, any>::value, _Decayed>;
@@ -430,8 +430,8 @@ inline namespace fundamentals_v1
       // If the type _Tp could never be stored in an any we don't want to
       // instantiate _Manager<_Tp>, so use _Manager<any::_Op> instead, which
       // is explicitly specialized and has a no-op _S_manage function.
-      using _Vp = conditional_t<__and_<__does_not_decay, __is_copyable>::value,
-                               _Up, any::_Op>;
+      using _Vp = __conditional_t<__and_<__does_not_decay, __is_copyable>{},
+                                 _Up, any::_Op>;
       // First try comparing function addresses, which works without RTTI
       if (__any->_M_manager == &any::_Manager<_Vp>::_S_manage
 #if __cpp_rtti
index 4322a7f5caf18b618be0d55fe1fd54c0ab69f7e1..e7a0c6e6d989328f133031ef13c69ce75abeed08 100644 (file)
@@ -389,7 +389,7 @@ inline namespace v1
        = typename __result_type::completion_handler_type;
 
     private:
-      using __handler_type = conditional_t<
+      using __handler_type = __conditional_t<
        is_same<_CompletionToken, completion_handler_type>::value,
        completion_handler_type&,
        completion_handler_type>;
index 0a2b9381d70655764a101952e2b779bce5c43409..8be2fab1e318d19d61eb77274c43e60da37b9202 100644 (file)
@@ -164,9 +164,9 @@ inline namespace fundamentals_v1
            typename _Val = typename iterator_traits<_RAIter>::value_type,
           typename _Diff = typename iterator_traits<_RAIter>::difference_type>
     using __boyer_moore_base_t
-      = std::conditional_t<std::__is_byte_like<_Val, _Pred>::value,
-                          __boyer_moore_array_base<_Diff, 256, _Pred>,
-                          __boyer_moore_map_base<_Val, _Diff, _Hash, _Pred>>;
+      = std::__conditional_t<std::__is_byte_like<_Val, _Pred>::value,
+                            __boyer_moore_array_base<_Diff, 256, _Pred>,
+                            __boyer_moore_map_base<_Val, _Diff, _Hash, _Pred>>;
 
   template<typename _RAIter, typename _Hash
             = std::hash<typename std::iterator_traits<_RAIter>::value_type>,
index 1fce95730eaf1c91588c3499454b6d6eb22b87cc..625cac619f09d26d16bbbfcaaae647360777e306 100644 (file)
@@ -102,9 +102,9 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
       struct _Manager_external; // creates contained object on the heap
 
     template<typename _Tp>
-      using _Manager = conditional_t<_Internal<_Tp>::value,
-                                    _Manager_internal<_Tp>,
-                                    _Manager_external<_Tp>>;
+      using _Manager = __conditional_t<_Internal<_Tp>::value,
+                                      _Manager_internal<_Tp>,
+                                      _Manager_external<_Tp>>;
 
     template<typename _Tp, typename _VTp = decay_t<_Tp>>
       using _Decay_if_not_any = enable_if_t<!is_same_v<_VTp, any>, _VTp>;
index 0b257926fd550cd869dc7729239a2cbf09157612..a13f67e4c7c0cd4e446ef8cfc19b72e50fa8c6d8 100644 (file)
@@ -1117,9 +1117,9 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
            typename _Val = typename iterator_traits<_RAIter>::value_type,
           typename _Diff = typename iterator_traits<_RAIter>::difference_type>
     using __boyer_moore_base_t
-      = conditional_t<__is_byte_like<_Val, _Pred>::value,
-                     __boyer_moore_array_base<_Diff, 256, _Pred>,
-                     __boyer_moore_map_base<_Val, _Diff, _Hash, _Pred>>;
+      = __conditional_t<__is_byte_like<_Val, _Pred>::value,
+                       __boyer_moore_array_base<_Diff, 256, _Pred>,
+                       __boyer_moore_map_base<_Val, _Diff, _Hash, _Pred>>;
 
   template<typename _RAIter, typename _Hash
             = hash<typename iterator_traits<_RAIter>::value_type>,
index b373e4f05c07156029299ba96823b616eec4254e..07eae0cf94bb7428a5ba18919492ea4623e2753b 100644 (file)
@@ -770,11 +770,11 @@ namespace __detail
   // Data members using this alias should use [[no_unique_address]] so that
   // they take no space when not needed.
   template<bool _Present, typename _Tp>
-    using __maybe_present_t = conditional_t<_Present, _Tp, _Empty>;
+    using __maybe_present_t = __conditional_t<_Present, _Tp, _Empty>;
 
   // Alias for a type that is conditionally const.
   template<bool _Const, typename _Tp>
-    using __maybe_const_t = conditional_t<_Const, const _Tp, _Tp>;
+    using __maybe_const_t = __conditional_t<_Const, const _Tp, _Tp>;
 
 } // namespace __detail
 
@@ -2920,9 +2920,9 @@ namespace views::__adaptor
          bool _M_trailing_empty = false;
 
        public:
-         using iterator_concept = conditional_t<forward_range<_Base>,
-                                                forward_iterator_tag,
-                                                input_iterator_tag>;
+         using iterator_concept = __conditional_t<forward_range<_Base>,
+                                                  forward_iterator_tag,
+                                                  input_iterator_tag>;
          // iterator_category defined in __lazy_split_view_outer_iter_cat
          using difference_type = range_difference_t<_Base>;
 
index 120c80a2b785232342b9f55c399fdfea25a6ddde..94a4f0afd3169ff51958516d35b25629eab98234 100644 (file)
@@ -66,8 +66,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
   // Use the Empty Base-class Optimization for empty, non-final types.
   template<typename _Tp>
     using __empty_not_final
-    = typename conditional<__is_final(_Tp), false_type,
-                          __is_empty_non_tuple<_Tp>>::type;
+    = __conditional_t<__is_final(_Tp), false_type,
+                     __is_empty_non_tuple<_Tp>>;
 
   template<size_t _Idx, typename _Head,
           bool = __empty_not_final<_Head>::value>
@@ -905,9 +905,9 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 
       _GLIBCXX20_CONSTEXPR
       tuple&
-      operator=(typename conditional<__assignable<const _Elements&...>(),
-                                    const tuple&,
-                                    const __nonesuch&>::type __in)
+      operator=(__conditional_t<__assignable<const _Elements&...>(),
+                               const tuple&,
+                               const __nonesuch&> __in)
       noexcept(__nothrow_assignable<const _Elements&...>())
       {
        this->_M_assign(__in);
@@ -916,9 +916,9 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 
       _GLIBCXX20_CONSTEXPR
       tuple&
-      operator=(typename conditional<__assignable<_Elements...>(),
-                                    tuple&&,
-                                    __nonesuch&&>::type __in)
+      operator=(__conditional_t<__assignable<_Elements...>(),
+                               tuple&&,
+                               __nonesuch&&> __in)
       noexcept(__nothrow_assignable<_Elements...>())
       {
        this->_M_assign(std::move(__in));
@@ -1274,9 +1274,9 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 
       _GLIBCXX20_CONSTEXPR
       tuple&
-      operator=(typename conditional<__assignable<const _T1&, const _T2&>(),
-                                    const tuple&,
-                                    const __nonesuch&>::type __in)
+      operator=(__conditional_t<__assignable<const _T1&, const _T2&>(),
+                               const tuple&,
+                               const __nonesuch&> __in)
       noexcept(__nothrow_assignable<const _T1&, const _T2&>())
       {
        this->_M_assign(__in);
@@ -1285,9 +1285,9 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 
       _GLIBCXX20_CONSTEXPR
       tuple&
-      operator=(typename conditional<__assignable<_T1, _T2>(),
-                                    tuple&&,
-                                    __nonesuch&&>::type __in)
+      operator=(__conditional_t<__assignable<_T1, _T2>(),
+                               tuple&&,
+                               __nonesuch&&> __in)
       noexcept(__nothrow_assignable<_T1, _T2>())
       {
        this->_M_assign(std::move(__in));
index a0010d960b2dba095df463bd23628006a2a852ee..35ff5806c5d47e1cc83bc60f4503b95c583c549c 100644 (file)
@@ -100,8 +100,24 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 
   // Metaprogramming helper types.
 
-  template<bool, typename, typename>
-    struct conditional;
+  template<bool>
+    struct __conditional
+    {
+      template<typename _Tp, typename>
+       using type = _Tp;
+    };
+
+  template<>
+    struct __conditional<false>
+    {
+      template<typename, typename _Up>
+       using type = _Up;
+    };
+
+  // More efficient version of std::conditional_t for internal use (and C++11)
+  template<bool _Cond, typename _If, typename _Else>
+    using __conditional_t
+      = typename __conditional<_Cond>::template type<_If, _Else>;
 
   /// @cond undocumented
   template <typename _Type>
@@ -126,12 +142,12 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 
   template<typename _B1, typename _B2>
     struct __or_<_B1, _B2>
-    : public conditional<_B1::value, _B1, _B2>::type
+    : public __conditional_t<_B1::value, _B1, _B2>
     { };
 
   template<typename _B1, typename _B2, typename _B3, typename... _Bn>
     struct __or_<_B1, _B2, _B3, _Bn...>
-    : public conditional<_B1::value, _B1, __or_<_B2, _B3, _Bn...>>::type
+    : public __conditional_t<_B1::value, _B1, __or_<_B2, _B3, _Bn...>>
     { };
 
   template<typename...>
@@ -149,12 +165,12 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 
   template<typename _B1, typename _B2>
     struct __and_<_B1, _B2>
-    : public conditional<_B1::value, _B2, _B1>::type
+    : public __conditional_t<_B1::value, _B2, _B1>
     { };
 
   template<typename _B1, typename _B2, typename _B3, typename... _Bn>
     struct __and_<_B1, _B2, _B3, _Bn...>
-    : public conditional<_B1::value, __and_<_B2, _B3, _Bn...>, _B1>::type
+    : public __conditional_t<_B1::value, __and_<_B2, _B3, _Bn...>, _B1>
     { };
 
   template<typename _Pp>
@@ -2491,11 +2507,11 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
     {
       typedef __remove_cvref_t<_Arg> _Argval;
       typedef _Res _Class::* _MemPtr;
-      typedef typename conditional<__or_<is_same<_Argval, _Class>,
+      typedef typename __conditional_t<__or_<is_same<_Argval, _Class>,
         is_base_of<_Class, _Argval>>::value,
         __result_of_memobj_ref<_MemPtr, _Arg>,
         __result_of_memobj_deref<_MemPtr, _Arg>
-      >::type::type type;
+      >::type type;
     };
 
   template<typename _MemPtr, typename _Arg, typename... _Args>
@@ -2506,10 +2522,10 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
     {
       typedef typename remove_reference<_Arg>::type _Argval;
       typedef _Res _Class::* _MemPtr;
-      typedef typename conditional<is_base_of<_Class, _Argval>::value,
+      typedef typename __conditional_t<is_base_of<_Class, _Argval>::value,
         __result_of_memfun_ref<_MemPtr, _Arg, _Args...>,
         __result_of_memfun_deref<_MemPtr, _Arg, _Args...>
-      >::type::type type;
+      >::type type;
     };
 
   // _GLIBCXX_RESOLVE_LIB_DEFECTS
index 19b2158690a9b4d03081f697e6a945d7c2a4e56f..ddeefd9b35e0cbe503610dd17a1ab34a2b593fce 100644 (file)
@@ -1096,7 +1096,7 @@ namespace __variant
       typename _AsV = decltype(__variant::__as(std::declval<_Variant>())),
       typename _Tp = variant_alternative_t<_Np, remove_reference_t<_AsV>>>
     using __get_t
-      = conditional_t<is_lvalue_reference_v<_Variant>, _Tp&, _Tp&&>;
+      = __conditional_t<is_lvalue_reference_v<_Variant>, _Tp&, _Tp&&>;
 
   // Return type of std::visit.
   template<typename _Visitor, typename... _Variants>
This page took 0.11418 seconds and 5 git commands to generate.