Weird usage of conditional operator (gt;?=)(条件运算符 (gt;?=) 的奇怪用法)
问题描述
我正在查看一些代码并看到类似这样的内容:
I was looking at some code and saw something like this:
int d = 1;
int somethingbigger = 2;
d >?= somethingbigger;
cout << d << endl;
我认为这应该输出 2.但我什至不能用 gcc 4.5.2 编译它.该代码是在 2005 年编写的,并使用 gcc 3.4.4 编译(不是 100% 确定).
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.
推荐答案
这是最大"赋值运算符,一个 GCC 扩展.
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.
自 4.0.1 起:
G++ 最小和最大运算符(<? 和>?)及其复合形式 (<?=) 和 >?=) 已被弃用并将被在未来的版本中删除.使用这些运算符的代码应该是修改为使用 std::min 和 std::max 代替.
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.
看起来 它们在 4.0.4 之前就消失了.
这篇关于条件运算符 (>?=) 的奇怪用法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:条件运算符 (>?=) 的奇怪用法
基础教程推荐
- C++结构和函数声明。为什么它不能编译? 2022-11-07
- 如何检查GTK+3.0中的小部件类型? 2022-11-30
- 在 C++ 中计算滚动/移动平均值 2021-01-01
- 这个宏可以转换成函数吗? 2022-01-01
- 静态库、静态链接动态库和动态链接动态库的 .lib 文件里面是什么? 2021-01-01
- 如何将 std::pair 的排序 std::list 转换为 std::map 2022-01-01
- 如何通过C程序打开命令提示符Cmd 2022-12-09
- 我有静态或动态 boost 库吗? 2021-01-01
- 如何在 C++ 中初始化静态常量成员? 2022-01-01
- 常量变量在标题中不起作用 2021-01-01
