开发者

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

This question already has answers here: Closed 12 years ago.

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?


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...


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 =.


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.


It doesn't compile also with GCC, and I've never heard of an operator <?=.

Anyway I would hazard a guess that a<?=b could have a semantics like: a = (a<b) ? b : a, but again, this is just a guess.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜