Skip to content

Instantly share code, notes, and snippets.

@danlark1

danlark1/fancy_pair.h

Last active Apr 13, 2020
Embed
What would you like to do?
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
You can’t perform that action at this time.