Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

standard hash function for pointer to std::string

21 views
Skip to first unread message

porp...@gmail.com

unread,
Oct 3, 2017, 12:35:01 PM10/3/17
to
Hi,

I have the following:
std::unordered_set<std::string*>

Will it hash by default (C++11 or higher) by address or by string ?
If so, is it the reasonably good solution to use the wrapper for std::hash<std::string> ?

thanks for clarification

Chris Vine

unread,
Oct 3, 2017, 1:25:48 PM10/3/17
to
The hash of a pointer is usually just a reinterpret_cast to std::size_t
(it is in gcc's libstdc++). Hashing by std::string does not look
sensible, but I don't know your use case nor what you want to be
clarified.
0 new messages