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 << std::boolalpha << (x == x+2) << std::endl; return 0; }