<? is an operator in C++, although it is hardly ever used. In fact, most compilers don't even support it! 1

What it does is to compare two variables/constants and return the smallest. So, for instance, int a = 5<?7 will give a the value of 5. It is not based upon the < operator, so if you want to use this on a custom class you will have to define the entire operator. Alternatively use the following templated code which uses <:

template <class T>
const T &operator <? (const T &a, const T &b){
  return (b<a)?b:a;
Be aware that while
  double a=4.5;
  double b=2.7;
does not create any warnings (at least not in DJGPP, even with the -Wall option), it does not do what it looks like it does. b is not modified in the last line! a is still 4.5 and b is still 2.7!.

So, why use <? ? It is a few characters less to type than min(a,b), and doesn't require any includes. The drawback is of course that many people will find it incompeensible and the lack of portability.

Be sure to check out <?=.

>? works similarly, except that it gives the maximum instead of the minimum.

1According to Gorgonzola, this operator actually only exists in g++, so be careful.

Log in or register to write something here or to contact authors.