In C++, the std::set::insert() only inserts a value if there is not already one with the same 'value'. By the same, does this mean operator== or does it mean one for which operator< is false for either ordering, or does it mean something else?
does it mean one for which operator< is false for either ordering?
Yes, if the set uses the default comparator and compares keys using <
. More generally, in an ordered container with comparator Compare
, two keys k1
and k2
are regarded as equivalent if !Compare(k1,k2) && !Compare(k2,k1)
.
Keys are not required to implement operator==
or anything else; they are just required to be comparable using the container's comparator to give a strict weak ordering.