Home > Fresh News > std::tie

std::tie

April 15th, 2015 Leave a comment Go to 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); }

  1. No comments yet.
  1. No trackbacks yet.
You must be logged in to post a comment.