Commit 0d67cd38 by Jonathan Wakely Committed by Jonathan Wakely

Define __type_identity_t alias and use for string_view

This defines the equivalent of C++2a's std::type_identity_t alias but
for use in C++11 and later. This can be used to replace __detail::__idt
in the string_view headers, which previously used common_type_t because
the one argument specialization of common_type_t was simply the identity
transform (which is no longer true).

	* include/experimental/string_view (__detail::__idt): Remove.
	(operator==, operator!=, operator<, operator>, operator<=, operator>=):
	Use __type_identity_t instead of __detail::__idt;
	* include/std/string_view (__detail::__idt): Remove.
	(operator==, operator!=, operator<, operator>, operator<=, operator>=):
	Use __type_identity_t instead of __detail::__idt;
	* include/std/type_traits (__type_identity_t): New alias template.

From-SVN: r273442
parent 804e2d06
2019-07-12 Jonathan Wakely <jwakely@redhat.com> 2019-07-12 Jonathan Wakely <jwakely@redhat.com>
* include/experimental/string_view (__detail::__idt): Remove.
(operator==, operator!=, operator<, operator>, operator<=, operator>=):
Use __type_identity_t instead of __detail::__idt;
* include/std/string_view (__detail::__idt): Remove.
(operator==, operator!=, operator<, operator>, operator<=, operator>=):
Use __type_identity_t instead of __detail::__idt;
* include/std/type_traits (__type_identity_t): New alias template.
* doc/xml/manual/status_cxx2020.xml: Update status for atomic_ref * doc/xml/manual/status_cxx2020.xml: Update status for atomic_ref
and floating point atomics. and floating point atomics.
......
...@@ -436,14 +436,10 @@ inline namespace fundamentals_v1 ...@@ -436,14 +436,10 @@ inline namespace fundamentals_v1
// [string.view.comparison], non-member basic_string_view comparison functions // [string.view.comparison], non-member basic_string_view comparison functions
namespace __detail // Several of these functions use type_identity_t to create a non-deduced
{ // context, so that only one argument participates in template argument
// Identity transform to create a non-deduced context, so that only one // deduction and the other argument gets implicitly converted to the deduced
// argument participates in template argument deduction and the other // type (see N3766).
// argument gets implicitly converted to the deduced type. See n3766.html.
template<typename _Tp>
using __idt = common_type_t<_Tp>;
}
template<typename _CharT, typename _Traits> template<typename _CharT, typename _Traits>
constexpr bool constexpr bool
...@@ -454,12 +450,13 @@ inline namespace fundamentals_v1 ...@@ -454,12 +450,13 @@ inline namespace fundamentals_v1
template<typename _CharT, typename _Traits> template<typename _CharT, typename _Traits>
constexpr bool constexpr bool
operator==(basic_string_view<_CharT, _Traits> __x, operator==(basic_string_view<_CharT, _Traits> __x,
__detail::__idt<basic_string_view<_CharT, _Traits>> __y) noexcept __type_identity_t<basic_string_view<_CharT, _Traits>> __y)
noexcept
{ return __x.size() == __y.size() && __x.compare(__y) == 0; } { return __x.size() == __y.size() && __x.compare(__y) == 0; }
template<typename _CharT, typename _Traits> template<typename _CharT, typename _Traits>
constexpr bool constexpr bool
operator==(__detail::__idt<basic_string_view<_CharT, _Traits>> __x, operator==(__type_identity_t<basic_string_view<_CharT, _Traits>> __x,
basic_string_view<_CharT, _Traits> __y) noexcept basic_string_view<_CharT, _Traits> __y) noexcept
{ return __x.size() == __y.size() && __x.compare(__y) == 0; } { return __x.size() == __y.size() && __x.compare(__y) == 0; }
...@@ -472,12 +469,13 @@ inline namespace fundamentals_v1 ...@@ -472,12 +469,13 @@ inline namespace fundamentals_v1
template<typename _CharT, typename _Traits> template<typename _CharT, typename _Traits>
constexpr bool constexpr bool
operator!=(basic_string_view<_CharT, _Traits> __x, operator!=(basic_string_view<_CharT, _Traits> __x,
__detail::__idt<basic_string_view<_CharT, _Traits>> __y) noexcept __type_identity_t<basic_string_view<_CharT, _Traits>> __y)
noexcept
{ return !(__x == __y); } { return !(__x == __y); }
template<typename _CharT, typename _Traits> template<typename _CharT, typename _Traits>
constexpr bool constexpr bool
operator!=(__detail::__idt<basic_string_view<_CharT, _Traits>> __x, operator!=(__type_identity_t<basic_string_view<_CharT, _Traits>> __x,
basic_string_view<_CharT, _Traits> __y) noexcept basic_string_view<_CharT, _Traits> __y) noexcept
{ return !(__x == __y); } { return !(__x == __y); }
...@@ -490,12 +488,13 @@ inline namespace fundamentals_v1 ...@@ -490,12 +488,13 @@ inline namespace fundamentals_v1
template<typename _CharT, typename _Traits> template<typename _CharT, typename _Traits>
constexpr bool constexpr bool
operator< (basic_string_view<_CharT, _Traits> __x, operator< (basic_string_view<_CharT, _Traits> __x,
__detail::__idt<basic_string_view<_CharT, _Traits>> __y) noexcept __type_identity_t<basic_string_view<_CharT, _Traits>> __y)
noexcept
{ return __x.compare(__y) < 0; } { return __x.compare(__y) < 0; }
template<typename _CharT, typename _Traits> template<typename _CharT, typename _Traits>
constexpr bool constexpr bool
operator< (__detail::__idt<basic_string_view<_CharT, _Traits>> __x, operator< (__type_identity_t<basic_string_view<_CharT, _Traits>> __x,
basic_string_view<_CharT, _Traits> __y) noexcept basic_string_view<_CharT, _Traits> __y) noexcept
{ return __x.compare(__y) < 0; } { return __x.compare(__y) < 0; }
...@@ -508,12 +507,13 @@ inline namespace fundamentals_v1 ...@@ -508,12 +507,13 @@ inline namespace fundamentals_v1
template<typename _CharT, typename _Traits> template<typename _CharT, typename _Traits>
constexpr bool constexpr bool
operator> (basic_string_view<_CharT, _Traits> __x, operator> (basic_string_view<_CharT, _Traits> __x,
__detail::__idt<basic_string_view<_CharT, _Traits>> __y) noexcept __type_identity_t<basic_string_view<_CharT, _Traits>> __y)
noexcept
{ return __x.compare(__y) > 0; } { return __x.compare(__y) > 0; }
template<typename _CharT, typename _Traits> template<typename _CharT, typename _Traits>
constexpr bool constexpr bool
operator> (__detail::__idt<basic_string_view<_CharT, _Traits>> __x, operator> (__type_identity_t<basic_string_view<_CharT, _Traits>> __x,
basic_string_view<_CharT, _Traits> __y) noexcept basic_string_view<_CharT, _Traits> __y) noexcept
{ return __x.compare(__y) > 0; } { return __x.compare(__y) > 0; }
...@@ -526,12 +526,13 @@ inline namespace fundamentals_v1 ...@@ -526,12 +526,13 @@ inline namespace fundamentals_v1
template<typename _CharT, typename _Traits> template<typename _CharT, typename _Traits>
constexpr bool constexpr bool
operator<=(basic_string_view<_CharT, _Traits> __x, operator<=(basic_string_view<_CharT, _Traits> __x,
__detail::__idt<basic_string_view<_CharT, _Traits>> __y) noexcept __type_identity_t<basic_string_view<_CharT, _Traits>> __y)
noexcept
{ return __x.compare(__y) <= 0; } { return __x.compare(__y) <= 0; }
template<typename _CharT, typename _Traits> template<typename _CharT, typename _Traits>
constexpr bool constexpr bool
operator<=(__detail::__idt<basic_string_view<_CharT, _Traits>> __x, operator<=(__type_identity_t<basic_string_view<_CharT, _Traits>> __x,
basic_string_view<_CharT, _Traits> __y) noexcept basic_string_view<_CharT, _Traits> __y) noexcept
{ return __x.compare(__y) <= 0; } { return __x.compare(__y) <= 0; }
...@@ -544,12 +545,13 @@ inline namespace fundamentals_v1 ...@@ -544,12 +545,13 @@ inline namespace fundamentals_v1
template<typename _CharT, typename _Traits> template<typename _CharT, typename _Traits>
constexpr bool constexpr bool
operator>=(basic_string_view<_CharT, _Traits> __x, operator>=(basic_string_view<_CharT, _Traits> __x,
__detail::__idt<basic_string_view<_CharT, _Traits>> __y) noexcept __type_identity_t<basic_string_view<_CharT, _Traits>> __y)
noexcept
{ return __x.compare(__y) >= 0; } { return __x.compare(__y) >= 0; }
template<typename _CharT, typename _Traits> template<typename _CharT, typename _Traits>
constexpr bool constexpr bool
operator>=(__detail::__idt<basic_string_view<_CharT, _Traits>> __x, operator>=(__type_identity_t<basic_string_view<_CharT, _Traits>> __x,
basic_string_view<_CharT, _Traits> __y) noexcept basic_string_view<_CharT, _Traits> __y) noexcept
{ return __x.compare(__y) >= 0; } { return __x.compare(__y) >= 0; }
......
...@@ -459,14 +459,10 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ...@@ -459,14 +459,10 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
// [string.view.comparison], non-member basic_string_view comparison function // [string.view.comparison], non-member basic_string_view comparison function
namespace __detail // Several of these functions use type_identity_t to create a non-deduced
{ // context, so that only one argument participates in template argument
// Identity transform to create a non-deduced context, so that only one // deduction and the other argument gets implicitly converted to the deduced
// argument participates in template argument deduction and the other // type (see N3766).
// argument gets implicitly converted to the deduced type. See n3766.html.
template<typename _Tp>
using __idt = common_type_t<_Tp>;
}
template<typename _CharT, typename _Traits> template<typename _CharT, typename _Traits>
constexpr bool constexpr bool
...@@ -477,12 +473,13 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ...@@ -477,12 +473,13 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
template<typename _CharT, typename _Traits> template<typename _CharT, typename _Traits>
constexpr bool constexpr bool
operator==(basic_string_view<_CharT, _Traits> __x, operator==(basic_string_view<_CharT, _Traits> __x,
__detail::__idt<basic_string_view<_CharT, _Traits>> __y) noexcept __type_identity_t<basic_string_view<_CharT, _Traits>> __y)
noexcept
{ return __x.size() == __y.size() && __x.compare(__y) == 0; } { return __x.size() == __y.size() && __x.compare(__y) == 0; }
template<typename _CharT, typename _Traits> template<typename _CharT, typename _Traits>
constexpr bool constexpr bool
operator==(__detail::__idt<basic_string_view<_CharT, _Traits>> __x, operator==(__type_identity_t<basic_string_view<_CharT, _Traits>> __x,
basic_string_view<_CharT, _Traits> __y) noexcept basic_string_view<_CharT, _Traits> __y) noexcept
{ return __x.size() == __y.size() && __x.compare(__y) == 0; } { return __x.size() == __y.size() && __x.compare(__y) == 0; }
...@@ -495,12 +492,13 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ...@@ -495,12 +492,13 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
template<typename _CharT, typename _Traits> template<typename _CharT, typename _Traits>
constexpr bool constexpr bool
operator!=(basic_string_view<_CharT, _Traits> __x, operator!=(basic_string_view<_CharT, _Traits> __x,
__detail::__idt<basic_string_view<_CharT, _Traits>> __y) noexcept __type_identity_t<basic_string_view<_CharT, _Traits>> __y)
noexcept
{ return !(__x == __y); } { return !(__x == __y); }
template<typename _CharT, typename _Traits> template<typename _CharT, typename _Traits>
constexpr bool constexpr bool
operator!=(__detail::__idt<basic_string_view<_CharT, _Traits>> __x, operator!=(__type_identity_t<basic_string_view<_CharT, _Traits>> __x,
basic_string_view<_CharT, _Traits> __y) noexcept basic_string_view<_CharT, _Traits> __y) noexcept
{ return !(__x == __y); } { return !(__x == __y); }
...@@ -513,12 +511,13 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ...@@ -513,12 +511,13 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
template<typename _CharT, typename _Traits> template<typename _CharT, typename _Traits>
constexpr bool constexpr bool
operator< (basic_string_view<_CharT, _Traits> __x, operator< (basic_string_view<_CharT, _Traits> __x,
__detail::__idt<basic_string_view<_CharT, _Traits>> __y) noexcept __type_identity_t<basic_string_view<_CharT, _Traits>> __y)
noexcept
{ return __x.compare(__y) < 0; } { return __x.compare(__y) < 0; }
template<typename _CharT, typename _Traits> template<typename _CharT, typename _Traits>
constexpr bool constexpr bool
operator< (__detail::__idt<basic_string_view<_CharT, _Traits>> __x, operator< (__type_identity_t<basic_string_view<_CharT, _Traits>> __x,
basic_string_view<_CharT, _Traits> __y) noexcept basic_string_view<_CharT, _Traits> __y) noexcept
{ return __x.compare(__y) < 0; } { return __x.compare(__y) < 0; }
...@@ -531,12 +530,13 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ...@@ -531,12 +530,13 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
template<typename _CharT, typename _Traits> template<typename _CharT, typename _Traits>
constexpr bool constexpr bool
operator> (basic_string_view<_CharT, _Traits> __x, operator> (basic_string_view<_CharT, _Traits> __x,
__detail::__idt<basic_string_view<_CharT, _Traits>> __y) noexcept __type_identity_t<basic_string_view<_CharT, _Traits>> __y)
noexcept
{ return __x.compare(__y) > 0; } { return __x.compare(__y) > 0; }
template<typename _CharT, typename _Traits> template<typename _CharT, typename _Traits>
constexpr bool constexpr bool
operator> (__detail::__idt<basic_string_view<_CharT, _Traits>> __x, operator> (__type_identity_t<basic_string_view<_CharT, _Traits>> __x,
basic_string_view<_CharT, _Traits> __y) noexcept basic_string_view<_CharT, _Traits> __y) noexcept
{ return __x.compare(__y) > 0; } { return __x.compare(__y) > 0; }
...@@ -549,12 +549,13 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ...@@ -549,12 +549,13 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
template<typename _CharT, typename _Traits> template<typename _CharT, typename _Traits>
constexpr bool constexpr bool
operator<=(basic_string_view<_CharT, _Traits> __x, operator<=(basic_string_view<_CharT, _Traits> __x,
__detail::__idt<basic_string_view<_CharT, _Traits>> __y) noexcept __type_identity_t<basic_string_view<_CharT, _Traits>> __y)
noexcept
{ return __x.compare(__y) <= 0; } { return __x.compare(__y) <= 0; }
template<typename _CharT, typename _Traits> template<typename _CharT, typename _Traits>
constexpr bool constexpr bool
operator<=(__detail::__idt<basic_string_view<_CharT, _Traits>> __x, operator<=(__type_identity_t<basic_string_view<_CharT, _Traits>> __x,
basic_string_view<_CharT, _Traits> __y) noexcept basic_string_view<_CharT, _Traits> __y) noexcept
{ return __x.compare(__y) <= 0; } { return __x.compare(__y) <= 0; }
...@@ -567,12 +568,13 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ...@@ -567,12 +568,13 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
template<typename _CharT, typename _Traits> template<typename _CharT, typename _Traits>
constexpr bool constexpr bool
operator>=(basic_string_view<_CharT, _Traits> __x, operator>=(basic_string_view<_CharT, _Traits> __x,
__detail::__idt<basic_string_view<_CharT, _Traits>> __y) noexcept __type_identity_t<basic_string_view<_CharT, _Traits>> __y)
noexcept
{ return __x.compare(__y) >= 0; } { return __x.compare(__y) >= 0; }
template<typename _CharT, typename _Traits> template<typename _CharT, typename _Traits>
constexpr bool constexpr bool
operator>=(__detail::__idt<basic_string_view<_CharT, _Traits>> __x, operator>=(__type_identity_t<basic_string_view<_CharT, _Traits>> __x,
basic_string_view<_CharT, _Traits> __y) noexcept basic_string_view<_CharT, _Traits> __y) noexcept
{ return __x.compare(__y) >= 0; } { return __x.compare(__y) >= 0; }
......
...@@ -92,9 +92,11 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ...@@ -92,9 +92,11 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
struct conditional; struct conditional;
template <typename _Type> template <typename _Type>
struct __type_identity { struct __type_identity
using type = _Type; { using type = _Type; };
};
template<typename _Tp>
using __type_identity_t = typename __type_identity<_Tp>::type;
template<typename...> template<typename...>
struct __or_; struct __or_;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment