It makes sense to compare an object of my class only with the literal 0, how can I limit the value of the argument of the overridden comparison operators to this value for checking at compile time?
It is required to get the behavior as in the example
class C {
public:
bool operator>(zero_literal_t n);
bool operator<(zero_literal_t n);
bool operator==(zero_literal_t n);
bool operator!=(zero_literal_t n);
bool operator>=(zero_literal_t n);
bool operator<=(zero_literal_t n);
};
int main()
{
C c;
int i0 = 0;
int i1 = 1;
auto v1 = c > 0; // Ok
auto v2 = c > 1; // Compile time error
auto v3 = c == 0; // Ok
auto v4 = c == 1; // Compile time error
auto v5 = c == i0; // Compile time error
auto v6 = c == i1; // Compile time error
return 0;
}