Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is <?= in C++? [duplicate]

Tags:

c++

Possible Duplicate:
C extension: <? and >? operators

Take a look at the top answer (by sclo) to problem D of this Google Code Jam. It's C++ code, it must have compiled, and it contains statements such as this one:

double& ret = F[mask][cur][b];
if(j==cur) {
  ret<?=f(tmp,j,b||bad[i])+M[cur][i];   // WTF is <?=   ???
}

This doesn't compile in my Visual Studio 2008. What does the <?= mean?

like image 994
ripper234 Avatar asked Jan 19 '11 10:01

ripper234


3 Answers

It's a gcc extension: C extension: <? and >? operators

Recent manuals say:

The G++ minimum and maximum operators (‘<?’ and ‘>?’) and their compound forms (‘<?=’) and ‘>?=’) have been deprecated and are now removed from G++. Code using these operators should be modified to use std::min and std::max instead...

like image 150
Luca Matteis Avatar answered Nov 03 '22 04:11

Luca Matteis


It's simply not valid C++. < Might be less than, an open angle bracket for a template argument list, or the start of a digraph however non of those can be followed by ?, then =.

like image 24
CB Bailey Avatar answered Nov 03 '22 03:11

CB Bailey


It's a now deprecated g++ extension 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.

There are also compound versions

<?=

and

>?=

that do assignment as well.

like image 3
plivesey Avatar answered Nov 03 '22 04:11

plivesey