C++ Logo

std-discussion

Advanced search

Re: Trying to solve how to do a std::unordered_map<std::pair<..., ...>, ...>

From: Edward Catmur <ecatmur_at_[hidden]>
Date: Mon, 2 Oct 2023 12:45:17 -0600
And don't try to specialize hash on unconstrained std::pair; it isn't
yours. Write a separate hash class to use explicitly if you must.

On Mon, Oct 2, 2023, 12:27 Giuseppe D'Angelo via Std-Discussion <
std-discussion_at_[hidden]> wrote:

> On 02/10/2023 19:45, Aaron Gray via Std-Discussion wrote:
> > size_t hash = 0;
> > hash ^= key.first ? std::hash<string>()(
> key.first->name ) :
> > std::hash<void *>()( nullptr );
> > hash ^= key.second ? std::hash<string>()(
> key.second->name ) :
> > std::hash<void *>()( nullptr );
> > return hash;
>
> Please don't do this; Use Boost.HashCombine or one of the techniques
> described by the newer hashing proposals.
>
> My 2 c,
> --
> Giuseppe D'Angelo
>
> --
> Std-Discussion mailing list
> Std-Discussion_at_[hidden]
> https://lists.isocpp.org/mailman/listinfo.cgi/std-discussion
>

Received on 2023-10-02 18:45:31