Sometimes I have structures like this -
struct aggregate1 {
std::string name;
std::vector<ValueT> options;
size_t foobar;
};
- where the (in) equality is simply defined as the (in) equality of all Member States: lhs_name == rhs_name && lhs_options == rhs_options && lhs_foobar == rhs_foobar.
What is the “best” way to implement this? (The best, as in: (Runtime-) Efficiency, maintainability, readability)
operator== in terms operator!=operator!= in terms operator==- Separate implementations for
==and!= - As a member or as free features?
Please note that this question concerns only (in) equality ops, as a comparison ( <, <=, ...) does not have much use for such units.
source
share