mardi 23 août 2016

What container to store unique values with no operator< defined

I need to store unique objects in a container. The object provides a operator== and operator!= (operator< nor operator>).

I can't use std::set, as it requires a operator<. I can't use std::unordered_set as it requires a hash function and I have none. Let's say I can't write one considering my object type (or I'm lazy).

Am I really forced to use a std::vector and make sure myself that items does not get duplicated in the container (using std::find which uses operator==)?

Is there really no container that could be used to store unique items only using the operator==?

Aucun commentaire:

Enregistrer un commentaire