Skip to content

Instantly share code, notes, and snippets.

@danlark1
Last active April 13, 2020 14:27
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 danlark1/42618dcdcd81894cc0805076a93af055 to your computer and use it in GitHub Desktop.
Save danlark1/42618dcdcd81894cc0805076a93af055 to your computer and use it in GitHub Desktop.
template <typename T, typename U>
struct pair {
T first;
U second;
constexpr std::strong_ordering operator<=>(const pair& other) const {
if (auto first_comp = first <=> other.first; first_comp != 0) {
return first_comp;
} else {
return second <=> other.second;
}
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment