diff options
author | Jonathan Wakely <jwakely@redhat.com> | 2024-03-20 11:07:56 +0000 |
---|---|---|
committer | Jonathan Wakely <jwakely@redhat.com> | 2024-03-23 11:07:57 +0000 |
commit | f4605c53ea2eeafc13e14dd1ad00a0caf80057e2 (patch) | |
tree | 6bd969aaf2fbd45be14a5ada58abfea90b94d6ca /libstdc++-v3/include | |
parent | 4a46a48ebc7b7b3976af49f6f8dabd65c6ddf64b (diff) | |
download | gcc-f4605c53ea2eeafc13e14dd1ad00a0caf80057e2.zip gcc-f4605c53ea2eeafc13e14dd1ad00a0caf80057e2.tar.gz gcc-f4605c53ea2eeafc13e14dd1ad00a0caf80057e2.tar.bz2 |
libstdc++: Use std::type_identity_t in <string_view> as per LWG 3950 [PR114400]
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.
Diffstat (limited to 'libstdc++-v3/include')
-rw-r--r-- | libstdc++-v3/include/std/string_view | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/libstdc++-v3/include/std/string_view b/libstdc++-v3/include/std/string_view index e30a9c1..a7c5a12 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 @@ -624,6 +624,14 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION [[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 + operator==(basic_string_view<_CharT, _Traits> __x, basic_string_view<_CharT, _Traits> __y) noexcept { return __x.size() == __y.size() && __x.compare(__y) == 0; } |