I have an int a that needs to be equal to \"infinity\". This means that if
int b = anyValue;
a>b is always tru
int is inherently finite; there's no value that satisfies your requirements.
If you're willing to change the type of b, though, you can do this with operator overrides:
class infinitytype {};
template
bool operator>(const T &, const infinitytype &) {
return false;
}
template
bool operator<(const T &, const infinitytype &) {
return true;
}
bool operator<(const infinitytype &, const infinitytype &) {
return false;
}
bool operator>(const infinitytype &, const infinitytype &) {
return false;
}
// add operator==, operator!=, operator>=, operator<=...
int main() {
std::cout << ( INT_MAX < infinitytype() ); // true
}