Is there any method or macro to simulate syntax "if(a <= b < c <= …)" to replace "if(a<=b && b < c && c <= …)"?

I want to find a method or macro which “a<=b && b < c” can rewrite as “a <= b < c”, because “a <= b < c” seems more straight forward and often seen in user requirement definition. Also “a<=b && b < c” needs to type “b” twice.

I searched about operators, but it seems (I think) only can add operation for custom class, but not alter the original operation. Also I know I can overload “bool operator>” but not sure I can add a new operation “int operator>” which returns the larger one. Also even operator overload works, a <= b < c will return c only, but not the true or false of statement “a <= b < c” (similar to MAX(c,MAX(b,a))).

Is there any method to simulate “a <= b < c <= …”?


Source: syntax

Leave a Reply