I was looking at some code and saw something like this:
int d = 1;
int somethingbigger = 2;
d >?= somethingbigger;
cout << d << endl;
I think this should output 2. But I can't even compile this with gcc 4.5.2. The code was written in 2005 and compiled with gcc 3.4.4 (not 100% sure).
Can someone explain how this works and why I can't compile this with a recent compiler.
This is the "maximum" assignment operator, a GCC extension.
If the extension is not enabled, then you will not be able to use this feature.
As of 4.0.1:
The G++ minimum and maximum operators (
<?
and>?
) and their compound forms (<?=
) and>?=
) have been deprecated and will be removed in a future version. Code using these operators should be modified to use std::min and std::max instead.
It looks like they were gone by 4.0.4.
That's not C++ code.
It's using a gnu-only extension, and is completely non-portable.
Just replace it with standard-compliant code:
if (d < somethingbigger) d = somethingbigger;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With