C/C++教程

c++: rvalue, prvalue, lvalue, glvalue

本文主要是介绍c++: rvalue, prvalue, lvalue, glvalue,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!

历史习惯问题,叫左值,可以放在等号左边的对象和函数。例如,如果E是一个指针类型的表达式,*E就是一个左值表达式,可以指向E指向的对象或函数。
— An lvalue (so called, historically, because lvalues could appear on the left-hand side of an assignment
expression) designates a function or an object. [ Example: If E is an expression of pointer type, then
*E is an lvalue expression referring to the object or function to which E points. As another example,
the result of calling a function whose return type is an lvalue reference is an lvalue. —end example ]

xvalue,也是是指向一个对象,但是通常快要终结的对象。xvalue是特定表达式牵扯rvalue引用的结果。
— An xvalue (an “eXpiring” value) also refers to an object, usually near the end of its lifetime (so that its
resources may be moved, for example). An xvalue is the result of certain kinds of expressions involving
rvalue references (8.3.2). [ Example: The result of calling a function whose return type is an rvalue
reference is an xvalue. —end example ]
glvalue是一般化的lvalue,是一个lvalue或者xvalue。
— A glvalue (“generalized” lvalue) is an lvalue or an xvalue.
rvalue,也是历史习惯的称号,rvalue可以出现在赋值符号的右边。rvalue是一个xvalue,临时对象或者是一个只,不关联任何对象。
— An rvalue (so called, historically, because rvalues could appear on the right-hand side of an assignment
expression) is an xvalue, a temporary object (12.2) or subobject thereof, or a value that is not associated
with an object.
prvalue,纯右值;就是不是xvalue的rvalue。
— A prvalue (“pure” rvalue) is an rvalue that is not an xvalue. [ Example: The result of calling a function
whose return type is not a reference is a prvalue. The value of a literal such as 12, 7.3e5, or true is
also a prvalue. —end example ]
每一个表达式只能属于其中的一种:lvalue,xvalue或者rvalue。
Every expression belongs to exactly one

在这里插入图片描述

这篇关于c++: rvalue, prvalue, lvalue, glvalue的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!