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)
commita09bb4a852f82af02b3f965358cd44b0aa266a5b
treee76d8e55f190069b983bcafcabe75e71cbca5671
parentcfb582f62791dfadc243d97d37f0b83ef77cf480
libstdc++: Add std::__conditional_t alias template

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