std::tie
struct S { A a; B b; C c; }; auto const S_fields = [](S const& obj) -> auto { return std::tie(obj.a, obj.b, obj.c); }; bool operator == (S const& lhs, S const& rhs) { return S_fields(lhs) == S_fields(rhs); } bool operator < (S const& lhs, S const& rhs) { return S_fields(lhs) < S_fields(rhs); }