]> git.ipfire.org Git - thirdparty/gcc.git/commit - libstdc++-v3/include/std/type_traits
libstdc++: Prefer const T to std::add_const_t<T>
authorJonathan Wakely <jwakely@redhat.com>
Thu, 7 Jul 2022 11:27:08 +0000 (12:27 +0100)
committerJonathan Wakely <jwakely@redhat.com>
Tue, 12 Jul 2022 08:13:45 +0000 (09:13 +0100)
commit8be17e2ac73d43fd9781b842d47b0c3df2578756
tree4393636500113baf69a570e1ba7bb65b15b96c0e
parent3723aedaad20a129741c2f6f3c22b3dd1220a3fc
libstdc++: Prefer const T to std::add_const_t<T>

For any typedef-name or template parameter, T, add_const_t<T> is
equivalent to T const, so we can avoid instantiating the std::add_const
class template and just say T const (or const T).

This isn't true for a non-typedef like int&, where int& const would be
ill-formed, but we shouldn't be using add_const_t<int&> anyway, because
we know what that type is.

The only place we need to continue using std::add_const is in the
std::bind implementation where it's used as a template template
parameter to be applied as a metafunction elsewhere.

libstdc++-v3/ChangeLog:

* include/bits/stl_iterator.h (__iter_to_alloc_t): Replace
add_const_t with const-qualifier.
* include/bits/utility.h (tuple_element<N, cv T>): Likewise for
all cv-qualifiers.
* include/std/type_traits (add_const, add_volatile): Replace
typedef-declaration with using-declaration.
(add_cv): Replace add_const and add_volatile with cv-qualifiers.
* include/std/variant (variant_alternative<N, cv T>): Replace
add_const_t, add_volatile_t and add_cv_t etc. with cv-qualifiers.
libstdc++-v3/include/bits/stl_iterator.h
libstdc++-v3/include/bits/utility.h
libstdc++-v3/include/std/type_traits
libstdc++-v3/include/std/variant