Last active
March 13, 2017 17:12
-
-
Save loliGothicK/90fc00512966c453551936b7c9399970 to your computer and use it in GitHub Desktop.
std::tieによる比較
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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