0

For example:

vector<int> v = {1, 2, 3};
unordered_set<vector<int>> s;
s.insert(v);

will gives error

no match for call to '(const std::hash >) (const std::vector&)' noexcept(declval()(declval()))>

JustWe
  • 4,250
  • 3
  • 39
  • 90

1 Answers1

1

Because most of the C++ containers don't? vector<bool> appears to have an explicit specialization, but that's the unusual case; typically, they didn't provide std::hash overloads for aggregate or collection types (possibly because they didn't want to lock in a hash combining algorithm applicable to arbitrary templated types).

ShadowRanger
  • 143,180
  • 12
  • 188
  • 271