libstdc++: Always define typedefs and hash functions for wide strings [PR 98725]
authorJonathan Wakely <jwakely@redhat.com>
Fri, 8 Oct 2021 13:24:18 +0000 (14:24 +0100)
committerJonathan Wakely <jwakely@redhat.com>
Fri, 8 Oct 2021 23:57:49 +0000 (00:57 +0100)
commit0afb9ebaab09b999f1d158ffc3fb906fdab9df67
tree4b8a8f44384d99733d8ea59f151f6bb9a44cc618
parentcfeff094e6410844d2324193610cb7a512d67713
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.
libstdc++-v3/include/bits/basic_string.h
libstdc++-v3/include/bits/char_traits.h
libstdc++-v3/include/bits/stringfwd.h
libstdc++-v3/include/debug/string
libstdc++-v3/include/experimental/string_view
libstdc++-v3/include/std/string
libstdc++-v3/include/std/string_view