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/std/string | |
parent | cfeff094e6410844d2324193610cb7a512d67713 (diff) | |
download | gcc-0afb9ebaab09b999f1d158ffc3fb906fdab9df67.zip gcc-0afb9ebaab09b999f1d158ffc3fb906fdab9df67.tar.gz gcc-0afb9ebaab09b999f1d158ffc3fb906fdab9df67.tar.bz2 |
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/std/string')
-rw-r--r-- | libstdc++-v3/include/std/string | 4 |
1 files changed, 0 insertions, 4 deletions
diff --git a/libstdc++-v3/include/std/string b/libstdc++-v3/include/std/string index 95412b6..af840e8 100644 --- a/libstdc++-v3/include/std/string +++ b/libstdc++-v3/include/std/string @@ -68,9 +68,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION #endif using u16string = basic_string<char16_t>; using u32string = basic_string<char32_t>; -#ifdef _GLIBCXX_USE_WCHAR_T using wstring = basic_string<wchar_t>; -#endif } // namespace pmr template<typename _Str> @@ -100,12 +98,10 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION struct hash<pmr::u32string> : public __hash_string_base<pmr::u32string> { }; -#ifdef _GLIBCXX_USE_WCHAR_T template<> struct hash<pmr::wstring> : public __hash_string_base<pmr::wstring> { }; -#endif _GLIBCXX_END_NAMESPACE_VERSION } // namespace std |