diff options
author | Jonathan Wakely <jwakely@redhat.com> | 2021-10-08 14:24:18 +0100 |
---|---|---|
committer | Jonathan Wakely <jwakely@redhat.com> | 2021-10-09 00:57:49 +0100 |
commit | 0afb9ebaab09b999f1d158ffc3fb906fdab9df67 (patch) | |
tree | 4b8a8f44384d99733d8ea59f151f6bb9a44cc618 /libstdc++-v3/include/experimental | |
parent | cfeff094e6410844d2324193610cb7a512d67713 (diff) |
libstdc++: Always define typedefs and hash functions for wide strings [PR 98725]
The wstring and wstring_view typedefs should be enabled even if
<wchar.h> isn't supported, because char_traits<wchar_t> works
unconditionally. Similarly, the std::hash specializations for wide
strings do not depend on <wchar.h> support.
Although the primary template works OK for std::char_traits<wchar_t> in
the absence of <wchar.h> support, this patch still defines it as an
explicit specialization for compatibility with declarations that expect
it to be specialized. The explicit specialization just uses the same
__gnu_cxx::char_traits base class as the primary template.
libstdc++-v3/ChangeLog:
PR libstdc++/98725
* include/bits/char_traits.h (char_traits<wchar_t>): Define
explicit specialization unconditionally.
* include/bits/basic_string.h (hash<wstring>): Define
unconditionally. Do not check _GLIBCXX_USE_WCHAR_T.
* include/bits/stringfwd.h (wstring): Likewise.
* include/debug/string (wstring): Likewise.
* include/experimental/string_view (experimental::wstring_view)
(hash<experimental::wstring_view>): Likewise.
* include/std/string (pmr::wstring, hash<pmr::wstring>):
Likewise.
* include/std/string_view (wstring_view, hash<wstring_view>):
Likewise.
Diffstat (limited to 'libstdc++-v3/include/experimental')
-rw-r--r-- | libstdc++-v3/include/experimental/string_view | 6 |
1 files changed, 0 insertions, 6 deletions
diff --git a/libstdc++-v3/include/experimental/string_view b/libstdc++-v3/include/experimental/string_view index d9bc5cd166d..b8e4db8ef30 100644 --- a/libstdc++-v3/include/experimental/string_view +++ b/libstdc++-v3/include/experimental/string_view @@ -564,9 +564,7 @@ inline namespace fundamentals_v1 // basic_string_view typedef names using string_view = basic_string_view<char>; -#ifdef _GLIBCXX_USE_WCHAR_T using wstring_view = basic_string_view<wchar_t>; -#endif #ifdef _GLIBCXX_USE_CHAR8_T using u8string_view = basic_string_view<char8_t>; #endif @@ -593,7 +591,6 @@ inline namespace fundamentals_v1 struct __is_fast_hash<hash<experimental::string_view>> : std::false_type { }; -#ifdef _GLIBCXX_USE_WCHAR_T template<> struct hash<experimental::wstring_view> : public __hash_base<size_t, wstring> @@ -607,7 +604,6 @@ inline namespace fundamentals_v1 template<> struct __is_fast_hash<hash<experimental::wstring_view>> : std::false_type { }; -#endif #ifdef _GLIBCXX_USE_CHAR8_T template<> @@ -665,11 +661,9 @@ namespace experimental operator""sv(const char* __str, size_t __len) noexcept { return basic_string_view<char>{__str, __len}; } -#ifdef _GLIBCXX_USE_WCHAR_T inline constexpr basic_string_view<wchar_t> operator""sv(const wchar_t* __str, size_t __len) noexcept { return basic_string_view<wchar_t>{__str, __len}; } -#endif #ifdef _GLIBCXX_USE_CHAR8_T inline constexpr basic_string_view<char8_t> |