Is it possible to use this kind of notation in the if statement?
Yes, possible.
Desirable, hardly ever: programmers presume the behaviours described in other answers will always apply, so if you dramatically change the order of evaluation and the meaning of an expression then it will really, badly confuse them and, sooner or later, cause grief. If you have a very small project with few staff, and they're basically looking to create a domain-specific language in C++, where the domain's notation is really much more readable and familiar using this notation (maybe their mathematicians not programmers anyway), then you might in extremis consider something like I present below, though it's still likely to cause trouble.
I've implemented this kind of thing before years ago as an academic exercise - if you wish to do so but need help getting started, and off the top of my head so doubtless buggy, consider:
struct Weird
{
Weird(int n) : n_(n), b_is_meaningful_(false) { }
Weird(int n, bool b) : n_(n), b_is_meaningful_(true), b_(b) { }
int n_;
bool b_is_meaningful_;
bool b_;
};
Weird operator<(Weird lhs, Weird rhs)
{
if (lhs.b_is_meaningful_)
if (!lhs.b_) // effectively, anding with something already known false...
return Weird(rhs.n_, false);
return Weird(rhs.n_, lhs.n_ < rhs.n_);
}
Basically, you hack it around until you can:
Weird x = 10;
assert(6 < x < 20 < 30 < Weird(80));
At each point, the operator< creates a new Weird object with the Right Hand Side (rhs) value, while updating the boolean state on the assumption that you're effectively anding together a set of comparisons. If you really want to make a mess, you can support all kinds of things in C++, you might have a crack at say "x == 6 || 3 || 56" for fun...?