Operator <?= in C/C++ [duplicate] - c++

This question already has answers here:
Closed 11 years ago.
Possible Duplicate:
C extension: <? and >? operators
What does the >?= operator mean?
I was googling some C++ codes on the internet and just found this:
num <?= num2-num3+num4;
Does anyone knows what this operator stands for? I googled for it but found anything.

It was a GCC extension at some point, now removed. It is the assignment version of <? which was simply the minimum operator. So that code reads "set num to num2-num3+num4 if that is smaller than num". In standard C++:
num = std::min(num, num2-num3+num4);

It's a gcc extension, basically means
num = std::min(num, rhs);

Related

Why do we use && and || while "and" and "or" also work? [duplicate]

This question already has answers here:
The written versions of the logical operators
(5 answers)
Closed 1 year ago.
I always use "and" and "or", but at college I learned that we should use && and ||...
This related to character encoding, the source code maybe not written in any non-ASCII 7-bit character (ex: ISO 646:1983) and serving compatibility to code that use this operator.
Reference:
Alternative Operator

why this works: C++ last statement as result of expression [duplicate]

This question already has answers here:
Are compound statements (blocks) surrounded by parens expressions in ANSI C?
(2 answers)
Warning "Use of GNU statement expression extension"
(4 answers)
Closed 7 years ago.
I found strange macros in a driver implementation that I can't explain to myself.
Simplified example is:
cout << ({int i=0; while(i<10) {++i;} i;}) << endl;
It will output 10.
But why this does expression become an rvalue at all? It seems to work in C and in C++.
Can someone explain me? Pointing to keywords and to reference will be great.
The is a GCC extension:
A compound statement enclosed in parentheses may appear as an
expression in GNU C.
The last thing in the compound statement should be an expression
followed by a semicolon; the value of this subexpression serves as the
value of the entire construct.

What does the | operator do in Qt? [duplicate]

This question already has answers here:
Bitwise OR of constants
(5 answers)
Closed 9 years ago.
In this answer, the answerer uses the | operator: Yes/No message box using QMessageBox
According to the documentation, that argument is supposed to be StandardButtons.
So the | operator merges two StandardButton into one StandardButtons?
I've tried looking through the Qt documentation, but there is none on operators. So it must be a C++ operator?
| is the bitwise OR operator, which is commonly used to combine enum values (assuming that the integers backing the enum values are powers of two). In this case, the code specifies that it wishes to have both a Yes and a No button. (Note that this is standard C++ syntax and nothing Qt specific.)

what does <?= meaning in C++ [duplicate]

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.

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.