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.
Related
I observed that there was at some point a <? and >? operator in GCC. How can I use these under GCC 4.5? Have they been removed, and if so, when?
Offset block_count = (cpfs->geo.block_size - block_offset) <? count;
cpfs.c:473: error: expected expression before ‘?’ token
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.
A quick search of the past documents seems to indicate that they were removed around version 4.0 (3.4.6 includes them, 4.0.4 does not).
Earlier iterations of g++ (not the C compiler) used these operators for giving you the minimum or maximum values but they've long been deprecated in favour of std::min and std::max.
Basically, they equated to (but without the possibility of double evaluation of a or b):
a <? b --> (a < b) ? a : b
a >? b --> (a > b) ? a : b
In terms of replacing them (and you really should replace them), you can use something like:
Offset block_count = cpfs->geo.block_size - block_offset;
if (block_count > count) block_count = count;
or equivalents using std::min.
I'm not a big fan of using C/C++ "extensions" (especially ones that have been deprecated and/or removed) since they tie me to a specific implementation of the language.
You should never use a non-standard extension where a perfectly adequate standard method is available.
I observed that there was at some point a <? and >? operator in GCC. How can I use these under GCC 4.5? Have they been removed, and if so, when?
Offset block_count = (cpfs->geo.block_size - block_offset) <? count;
cpfs.c:473: error: expected expression before ‘?’ token
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.
A quick search of the past documents seems to indicate that they were removed around version 4.0 (3.4.6 includes them, 4.0.4 does not).
Earlier iterations of g++ (not the C compiler) used these operators for giving you the minimum or maximum values but they've long been deprecated in favour of std::min and std::max.
Basically, they equated to (but without the possibility of double evaluation of a or b):
a <? b --> (a < b) ? a : b
a >? b --> (a > b) ? a : b
In terms of replacing them (and you really should replace them), you can use something like:
Offset block_count = cpfs->geo.block_size - block_offset;
if (block_count > count) block_count = count;
or equivalents using std::min.
I'm not a big fan of using C/C++ "extensions" (especially ones that have been deprecated and/or removed) since they tie me to a specific implementation of the language.
You should never use a non-standard extension where a perfectly adequate standard method is available.
Looking through this C++ BigInt library and found the BigInt.cpp file. At the top there is a a comment at the top about compatibility:
This class was written for the g++ compiler and uses some of the g++ extensions (like "long double" and the ">?=" operator).
What does that >?= operator do? I can't find a reference to it anywhere else.
It's a GCC extension that was removed in GCC version 4.2 and later.
The equivalent of a >?= b is a = max(a,b);
There is also a very similar operator a <?= b which means the same as a = min(a, b);.
This page describes that >? is the 'maximum' operator, which returns the largest of its two numeric arguments. I'm guessing that the >?= combines this with assignment, presumably by assigning to the left-hand operand if the right-hand value is larger.
See C extension: <? and >? operators
It's the max-then-assign operator: Take the greater of the left and right sides and stuff it back into the lefthand side.
It's removed from g++ and should be replaced with max (or min for <?=)
This question already has answers here:
Closed 11 years ago.
Possible Duplicates:
C++ weird usage of conditional operator (>?=)
C extension: <? and >? operators
When i read a C++ code,i see the following lines:
void add(double v) { min <?= v; max >?= v; StatFig::add(v); }
What does the
>?=
means?
Thanks.
Answered right here: Link.
As explained by the great answer there which i in no way take credit for, it's a deprecated GCC extension, and in no way standard C++. Avoid.
There is a list of operators in C++ on wikipedia, but it's not in here, so maybe it's defined elsewhere in the code you read.
My guess would be that's it's an assignement operator that checks if the value is lower/higher than a certain threshold, and if so assigns that threshold to the variable. Or something
In other words, min <?= v might be equivalent to min=((min<v)?min:v), but that's just a guess.
I ran across the following lines of C++ code in a file (non-contiguous lines) that gcc 4.2.1 won't accept:
int frame = blk <? mBlkCnt-1;
mInsCnt = blk <? mBlkCnt;
mInsCnt = mInsCnt+1 <? mBlkCnt;
const int to_read = (mFileSz-byte_off) <? mBlkSz;
Both <? and >? are used in various places in the code. They appear to be a shorthand for assigning the smaller (or larger) of two values, but I've never seen this operator combination. Any ideas on what this is?
They're called the min and max operators and were language extensions in earlier versions of gcc.
They are no longer supported.
It's not a C++ operator, that's for sure. It almost resembles a digraph, but certainly not a valid one. In any case, a digraph, if supported, would just result in punctuation, not a whole new operator.
So, in answer to your question, perhaps this file needs to be preprocessed by some preprocessor that converts it to valid C++.