Skip to content

Instantly share code, notes, and snippets.

@loliGothicK
Last active March 13, 2017 17:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save loliGothicK/90fc00512966c453551936b7c9399970 to your computer and use it in GitHub Desktop.
Save loliGothicK/90fc00512966c453551936b7c9399970 to your computer and use it in GitHub Desktop.
std::tieによる比較
#include <tuple>
#include <string>
struct Person {
std::string first_name;
std::string last_name;
int age;
};
bool operator<(const Person& x, const Person& y)
{
// std::tie関数でタプル作成&std::tupleの比較演算子で比較
return std::tie(x.last_name, x.first_name, x.age) < std::tie(y.last_name, y.first_name, y.age);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment