C++ Logo

std-discussion

Advanced search

Re: [Suspected Spam] Trying to solve how to do a std::unordered_map<std::pair<..., ...>, ...>

From: Hans Åberg <haberg-1_at_[hidden]>
Date: Mon, 2 Oct 2023 20:36:55 +0200
> On Oct 2, 2023, at 11:33, Aaron Gray via Std-Discussion <std-discussion_at_[hidden]> wrote:
>
> I am trying to work out how to do a :-
>
> std::unordered_map<std::pair<const Type *, const Type*>, bool,
> std::hash<Type>> subTypeMemorization;

When working with namespaces, it used to be that one had to put the hash function in std:

namespace my {
  …
} // namespace my

namespace std {
  template<> struct hash<mli::level> {
    size_t operator()(my::type_t& x) const {
      return std::hash<unsigned>()(x.top) ^ std::hash<unsigned>()(x.bot);
    }
  };
} // namespace std

namespace my {
  …
} // namespace my

Received on 2023-10-02 18:37:08