diff mbox series

[committed] libstdc++: Use std::type_identity_t in <string_view> as per LWG 3950 [PR114400]

Message ID 20240323110929.426054-1-jwakely@redhat.com
State New
Headers show
Series [committed] libstdc++: Use std::type_identity_t in <string_view> as per LWG 3950 [PR114400] | expand

Commit Message

Jonathan Wakely March 23, 2024, 11:09 a.m. UTC
Tested aarch64-linux. Pushed to trunk.

-- >8 --

The difference between __type_identity_t and std::type_identity_t is
observable, as demonstrated in the PR. Nobody in LWG seems to think this
an example we should really care about, but it seems easy and harmless
to change this.

libstdc++-v3/ChangeLog:

	PR libstdc++/114400
	* include/std/string_view (operator==): Use std::type_identity_t
	in C++20 instead of our own __type_identity_t.
---
 libstdc++-v3/include/std/string_view | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)
diff mbox series

Patch

diff --git a/libstdc++-v3/include/std/string_view b/libstdc++-v3/include/std/string_view
index e30a9c1768e..a7c5a126461 100644
--- a/libstdc++-v3/include/std/string_view
+++ b/libstdc++-v3/include/std/string_view
@@ -602,15 +602,15 @@  _GLIBCXX_BEGIN_NAMESPACE_VERSION
   // deduction and the other argument gets implicitly converted to the deduced
   // type (see N3766).
 
+#if __cpp_lib_three_way_comparison
   template<typename _CharT, typename _Traits>
     [[nodiscard]]
     constexpr bool
     operator==(basic_string_view<_CharT, _Traits> __x,
-               __type_identity_t<basic_string_view<_CharT, _Traits>> __y)
+	       type_identity_t<basic_string_view<_CharT, _Traits>> __y)
     noexcept
     { return __x.size() == __y.size() && __x.compare(__y) == 0; }
 
-#if __cpp_lib_three_way_comparison
   template<typename _CharT, typename _Traits>
     [[nodiscard]]
     constexpr auto
@@ -620,6 +620,14 @@  _GLIBCXX_BEGIN_NAMESPACE_VERSION
     -> decltype(__detail::__char_traits_cmp_cat<_Traits>(0))
     { return __detail::__char_traits_cmp_cat<_Traits>(__x.compare(__y)); }
 #else
+  template<typename _CharT, typename _Traits>
+    [[nodiscard]]
+    constexpr bool
+    operator==(basic_string_view<_CharT, _Traits> __x,
+	       __type_identity_t<basic_string_view<_CharT, _Traits>> __y)
+    noexcept
+    { return __x.size() == __y.size() && __x.compare(__y) == 0; }
+
   template<typename _CharT, typename _Traits>
     [[nodiscard]]
     constexpr bool