pmr::string and friendsSection: 27.4.6 [basic.string.hash], 27.4.2 [string.syn] Status: C++20 Submitter: Tim Song Opened: 2017-06-14 Last modified: 2021-02-25
Priority: 0
View all other issues in [basic.string.hash].
View all issues with C++20 status.
Discussion:
In most cases, std::pmr::meow is a drop-in replacement for std::meow. The exception is
std::pmr::{,w,u16,u32}string, because unlike their std:: counterparts, they don't come with enabled
std::hash specializations.
The P/R below simply adds std::hash specializations for those four typedefs. An alternative approach, for which wording can be
produced if desired, is to make the hash specializations for basic_string allocator-agnostic, similar to the partial
specialization of hash for vector<bool>.
[2017-07 Toronto Monday issue prioritization]
Priority 0; move to Ready
Proposed resolution:
This wording is relative to N4659.
Edit 27.4.2 [string.syn], header <string> synopsis, as indicated:
namespace pmr {
template <class charT, class traits = char_traits<charT>>
using basic_string = std::basic_string<charT, traits, polymorphic_allocator<charT>>;
using string = basic_string<char>;
using u16string = basic_string<char16_t>;
using u32string = basic_string<char32_t>;
using wstring = basic_string<wchar_t>;
}
// 27.4.6 [basic.string.hash], hash support
template<class T> struct hash;
template<> struct hash<string>;
template<> struct hash<u16string>;
template<> struct hash<u32string>;
template<> struct hash<wstring>;
template<> struct hash<pmr::string>;
template<> struct hash<pmr::u16string>;
template<> struct hash<pmr::u32string>;
template<> struct hash<pmr::wstring>;
namespace pmr {
template <class charT, class traits = char_traits<charT>>
using basic_string = std::basic_string<charT, traits, polymorphic_allocator<charT>>;
using string = basic_string<char>;
using u16string = basic_string<char16_t>;
using u32string = basic_string<char32_t>;
using wstring = basic_string<wchar_t>;
}
Edit 27.4.6 [basic.string.hash] as indicated:
template<> struct hash<string>; template<> struct hash<u16string>; template<> struct hash<u32string>; template<> struct hash<wstring>; template<> struct hash<pmr::string>; template<> struct hash<pmr::u16string>; template<> struct hash<pmr::u32string>; template<> struct hash<pmr::wstring>;-1- If
Sis one of these string types,SVis the corresponding string view type, andsis an object of typeS, thenhash<S>()(s) == hash<SV>()(SV(s)).