Here is a solution for C++ based on operator overloading. It relies on implicit conversion from an `enum` to an `int`. #include <iostream> enum X {}; bool operator==(X x, int y) { return true; } int main() { X x; std::cout << ((x == x+2) ? "true" : "false") << std::endl; return 0; }