Created
October 28, 2014 14:30
-
-
Save Jules-Baratoux/6a7b5e992fcbf5ff6c8c 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
#include <cassert> | |
template <typename T> | |
struct proxy | |
{ | |
const T& value; | |
bool previous; | |
proxy(const T& value, bool previous) : value(value), previous(previous) {} | |
operator bool () | |
{ | |
return previous; | |
} | |
proxy<T> operator or (const T& rhs) | |
{ | |
return proxy<T>(value, previous or value == rhs); | |
} | |
}; | |
template <typename T> | |
proxy<T> operator == (const T& lhs, const T& rhs) | |
{ | |
return proxy<T>(lhs, lhs == rhs); | |
} | |
int main() | |
{ | |
assert(5 != 6); | |
assert(5 == 5); | |
assert(5 == 5 or 6); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment