Ternary comparison operator overloading

前端 未结 2 1931
不思量自难忘°
不思量自难忘° 2021-01-14 18:24

How would one implement a ternary comparison operator to determine, for example, the boolean value of a < b < c?

2条回答
  •  再見小時候
    2021-01-14 19:21

    Why do you need an operator?

    inline bool RangeCheck(int a, int b, int c)
    {
      return a < b && b < c;
    }
    

    or:

    #define RANGE_CHECK(a, b, c) (((a) < (b)) && ((b) < (c)))
    

提交回复
热议问题