29

I found the below code and don't understand what it means:

res>?=m[2];

Here's the code to where I found it and some context for it.

vector<int> m(3);
int s = 0;
... do stuff with m ...
res>?=m[2];
return res;
aled1027
  • 1,326
  • 2
  • 13
  • 17
  • 1
    link are available for registered users only. Can you at leas show what type the res variable has? – klm123 Nov 30 '13 at 19:52
  • 3
    This is definitely on SO somewhere already. You'll probably find the one I'm remembering [in here](http://symbolhound.com/?q=%3E%3F%3D). It's an old GCC extension. – chris Nov 30 '13 at 19:53

2 Answers2

37

It is an old GCC extension.

The equivalent of a >?= b is a = max(a,b);

You may check out Minimum and Maximum Operators in C++

It is very convenient to have operators which return the "minimum" or the "maximum" of two arguments. In GNU C++ (but not in GNU C),

a <? b

is the minimum, returning the smaller of the numeric values a and b;

a >? b

is the maximum, returning the larger of the numeric values a and b.

On a side note:-

These operators are non-standard and are deprecated in GCC. You should use std::min and std::max instead.

Community
  • 1
  • 1
Rahul Tripathi
  • 168,305
  • 31
  • 280
  • 331
7

This is certainly not standard C++. I can guess that is shortcut for the assignment + ternary operator, simmilary to assignment + binary operators, like operator+= and others:

 res = (res > m[2]) ? res : m[2];

You can read related here: Extensions to the C++ Language :

a <? b
is the minimum, returning the smaller of the numeric values a and b;
a >? b
is the maximum, returning the larger of the numeric values a and b.
klm123
  • 12,105
  • 14
  • 57
  • 95