std::unordered_set<my_type> my_set;
Which requirements must my_type fulfill here? (Besides a specialization for std::hash)
std::unordered_set<my_type> my_set;
Which requirements must my_type fulfill here? (Besides a specialization for std::hash)
You need a specialization for std::hash, and you need an operator == defined to handle hash collisions.
EDIT: You should also make sure your type has a copy constructor (or let the compiler generate one for you) because STL containers have value semantics.
EDIT2: as an example of how to do this, you can check out this other SO answer.
std::unordered_set<>
instance will also not be copyable. I.e., move-only is fine as long as you're okay with the std::unordered_set<>
instance also being move-only. –
Lamm © 2022 - 2024 — McMap. All rights reserved.