What is the name of the “-->” operator?(Stackoverflow)
Question:
After reading Hidden Features and Dark Corners of C++/STL on comp.lang.c++.moderated, I was completely surprised that it compiled and worked in both Visual Studio 2008 and G++ 4.4.
The code:
#include <stdio.h>
int main()
{
int x = 10;
while( x --> 0 ) // x goes to 0
{
printf("%d ", x);
}
}
I'd assume this is C, since it works in GCC as well. Where is this defined in the standard, and where has it come from?
Answer:
That's not an operator -->
. That's two separate operators,
and
-->
.
The condition code is decrementing x
, while returning x
's original (not decremented) value, and then comparing the original value with
0
using the >
operator.
To better understand, the statement could be written as follows:
while( (x--) > 0 )
What is the name of the “-->” operator?(Stackoverflow)的更多相关文章
- The Safe Navigation Operator (&.) in Ruby
The most interesting addition to Ruby 2.3.0 is the Safe Navigation Operator(&.). A similar opera ...
- Blender 脚本之 Operator 初探
addon(插件)用来扩展 Blender 的功能,跟其他软件里的 plugin(插件)一样,去掉不会影响软件的运行.插件可以加到 Blender 的用户偏好设置目录里,或者就在你所编辑的.blend ...
- Sequence Project Showplan Operator 序列映射运算符
Sequence Project Showplan Operator 序列映射运算符 序列映射运算符会从一个已经排序的集合里通过不停添加集合里的列执行计算. 运算符根据一个或多个列的值把输入集合分为多 ...
- [c++] Operator overloading
c++的操蛋属性:自己为一档,空一档,其他随意. UB_stack a; UB_stack b = a; // copy auto c = a; auto d {a}; // (or auto d = ...
- EC笔记:第二部分:11:在operator=中处理“自我赋值”
已经一年半没有写过博客了,最近发现学过的知识还是需要整理一下,为知笔记,要开始收费了以前写在为知笔记上笔记也会慢慢的转到博客里. 话不多说,进入正题. 考虑考虑以下场景: 当某个对象对自身赋值时,会出 ...
- Swift学习(一):自定义运算符 operator
自定义运算符仅能包含这些字符: / = - + * % < >!& | ^.~ 运算符位置: 前置运算符 prefix 中间运算符 infix 后置运算符 postfix 运算符其 ...
- Bash 4.4 中新增的 ${parameter@operator} 语法
Bash 4.4 中新增了一种 ${...} 语法,长这样:${parameter@operator}.根据不同的 operator,它展开后的值可能是 parameter 这个参数的值经过某种转换后 ...
- 为什么operator>>(istream&, string&)能够安全地读入长度未知的字符串?
一般而言,实现"读入用户输入的字符串",程序中自然不能对用户输入的长度有所限定.这在C++中很容易实现,而在C中确没那么容易. 这一疑问,我在刚学C++的时候也在脑中闪现过:不过很 ...
- tensorflow添加自定义的auc计算operator
tensorflow可以很方便的添加用户自定义的operator(如果不添加也可以采用sklearn的auc计算函数或者自己写一个 但是会在python执行,这里希望在graph中也就是c++端执行这 ...
随机推荐
- 2.1博客系统 |基于form组件和Ajax实现注册登录
基于forms组件和Ajax实现注册功能 1 基于forms组件设计注册页面 --点击头像 === 点击input --头像预览: 修改用户选中的文件对象:获取文件对象的路径:修改img的src属性, ...
- [洛谷P3014][USACO11FEB]牛线Cow Line (康托展开)(数论)
如果在阅读本文之前对于康托展开没有了解的同学请戳一下这里: 简陋的博客 百度百科 题目描述 N(1<=N<=20)头牛,编号为1...N,正在与FJ玩一个疯狂的游戏.奶牛会排成一行 ...
- 数据操作流DataOutputStream、DataInputStream类
[例子1] import java.io.DataOutputStream; import java.io.File; import java.io.FileOutputStream; import ...
- JS-最全的创建对象的方式
JS最全创建对象方式汇总 1.最简单的方式--创建一个Object实例 var person = new Object(); //创建实例 person.name = "BlueBeginn ...
- 潭州课堂25班:Ph201805201 WEB 之 jQuery 第七课 (课堂笔记)
jq 的导入 <body> <script src="https://cdn.bootcss.com/jquery/3.3.1/jquery.js">< ...
- Java表达式转型规则
Java表达式转型规则由低到高转换: 1.所有的byte,short,char型的值将被提升为int型: 2.如果有一个操作数是long型,计算结果是long型: 3.如果有一个操作数是float型, ...
- 20172302 《Java软件结构与数据结构》第一周学习总结
2018下半年学习总结博客总目录:第一周 教材学习内容总结 第一章 概述 1.软件质量 软件工程(Software Engineering)是一门关于高质量软件开发的技术和理论的学科. 软件质量从以下 ...
- nginx image_filter 配置记录
nginx_image_filter http_image_filter_module 配置 ---------------------------------- 第一种: //官方配置 locati ...
- strcpy和memcpy的差别
strcpy和memcpy都是标准C库函数.它们有以下的特点. strcpy提供了字符串的复制. 即strcpy仅仅用于字符串复制.而且它不仅复制字符串内容之外,还会复制字符串的结束符,strcpy_ ...
- block 相关清单
对Objective-C中Block的追探 李博士