Last active
March 9, 2017 13:41
-
-
Save fastasturtle/925834f19e9e95c5b66d90cddfc05758 to your computer and use it in GitHub Desktop.
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
namespace ops { | |
struct gatekeeper {}; | |
template<typename T> | |
bool operator>(T const &a, T const &b) { | |
return b < a; | |
} | |
template<typename T> | |
bool operator==(T const &a, T const &b) { | |
return !(a < b) && !(b < a); | |
} | |
// ... | |
} | |
struct my_struct : private ops::gatekeeper { | |
int a; | |
my_struct(int a) : a{a} {} | |
bool operator<(my_struct const& other) const { | |
return a < other.a; | |
} | |
bool operator==(my_struct const& other) const { | |
return a == other.a; | |
} | |
}; | |
void test(my_struct s1, my_struct s2) { | |
s1 < s2; | |
s1 > s2; | |
s1 == s2; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment