免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 1545 | 回复: 1
打印 上一主题 下一主题

[C++] 不理解 c++的value categories [复制链接]

论坛徽章:
2
2015年辞旧岁徽章
日期:2015-03-03 16:54:152015元宵节徽章
日期:2015-03-06 15:52:30
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2016-07-14 10:01 |只看该作者 |倒序浏览
本帖最后由 neodreamerus 于 2016-07-14 10:02 编辑

lvalue 和 rvalue本来是理解的。
但是下面的解释中lvalue 和 rvalue 是借助 glvalue prvalue xvalue这几个概念解释的,
反而弄不懂了。

哪位大神给点拨我一下,谢谢


摘自 http://en.cppreference.com/w/cpp/language/value_category

Value categories

C++  C++ language  Expressions
Each C++ expression (an operator with its operands, a literal, a variable name, etc.) is characterized by two independent properties: a type and a value category. Each expression has some non-reference type, and each expression belongs to exactly one of the three primary value categories: prvalue, xvalue, lvalue, defined as follows:
a glvalue is an expression whose evaluation determines the identity of an object, bit-field, or function
a prvalue is an expression whose evaluation either
computes the value of the operand of an operator (such prvalue has no result object), or
initializes an object or a bit-field (such prvalue is said to have a result object). All class and array prvalues have a result object even if it is discarded.
an xvalue is a glvalue that denotes an object or bit-field whose resources can be reused
an lvalue is a glvalue that is not an xvalue.
an rvalue is a prvalue or an xvalue.

论坛徽章:
72
20周年集字徽章-20	
日期:2020-10-28 14:04:30操作系统版块每日发帖之星
日期:2016-07-13 06:20:0015-16赛季CBA联赛之广夏
日期:2016-07-10 09:04:02数据库技术版块每日发帖之星
日期:2016-07-09 06:20:00操作系统版块每日发帖之星
日期:2016-07-09 06:20:00数据库技术版块每日发帖之星
日期:2016-07-07 06:20:00操作系统版块每日发帖之星
日期:2016-07-07 06:20:00操作系统版块每日发帖之星
日期:2016-07-04 06:20:00数据库技术版块每日发帖之星
日期:2016-07-03 06:20:00操作系统版块每日发帖之星
日期:2016-07-03 06:20:00数据库技术版块每日发帖之星
日期:2016-07-02 06:20:00操作系统版块每日发帖之星
日期:2016-07-02 06:20:00
2 [报告]
发表于 2016-07-21 18:11 |只看该作者
彻底懵逼了。。。。
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP