Hi Everyone,
quick question:
colony/hive is unordered in terms of insertion position (but sortable),
should the ==/!= operator also be unordered ie.
should hive<int> {1,2, 3} == hive<int> {3, 1, 2}?
My main interest is not which is more 'correct' but which is more useful
in practice?
I don't use == operator for containers a lot so I don't know.
Be aware this will affect >= < etc also.
Another option to be considered is: you can provide no operator== at all.
Compare to std::unordered_set<T>, which provides an order-insensitive operator== and no operator<=>.
Compare to sg14::slot_map<T>, which provides no operator==.
You need to decide whether order is salient. (Salient properties, such as vector::size, are compared by operator== and copied by the copy ctor. Non-salient properties, such as vector::capacity, are not.)
One thing to consider is that copies are equal by definition.
std::hive<T> a = { ... };
std::hive<T> b = a;
assert(a == b); // if operator== is provided at all, then this must be true
You mustn't ever provide an operator== that breaks this invariant. Maybe that greatly simplifies your decision, maybe it doesn't, I don't know.
HTH,
Arthur