Archive

Archive for April, 2015

std::tie

April 15th, 2015 No comments
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); }