c11draftn1570
6.3.2Otheroperands
6.3.2.1Lvalues,arrays,andfunctiondesignators
1Anlvalueisanexpression(withanobjecttypeotherthanvoid)thatpotentiallydesignatesanobject;ifanlvaluedoesnotdesignateanobjectwhenitisevaluated,thebehaviorisundefined.Whenanobjectissaidtohaveaparticulartype,thetypeisspecifiedbythelvalueusedtodesignatetheobject.Amodifiablelvalueisanlvaluethatdoesnothavearraytype,doesnothaveanincompletetype,doesnothaveaconstqualifiedtype,andifitisastructureorunion,doesnothaveanymember(including,recursively,anymemberorelementofallcontainedaggregatesorunions)withaconstqualifiedtype.
c++14draftn4296
3.10Lvaluesandrvalues[basic.lval]
1ExpressionsarecategorizedaccordingtothetaxonomyinFigure1.
(1.1)—Anlvalue(socalled,historically,becauselvaluescouldappearontheleft-handsideofanassignment
expression)designatesafunctionoranobject.[Example:IfEisanexpressionofpointertype,then
*EisanlvalueexpressionreferringtotheobjectorfunctiontowhichEpoints.Asanotherexample,
theresultofcallingafunctionwhosereturntypeisanlvaluereferenceisanlvalue.—endexample]
(1.2)—Anxvalue(an“eXpiring”value)alsoreferstoanobject,usuallyneartheendofitslifetime(sothatits
resourcesmaybemoved,forexample).Certainkindsofexpressionsinvolvingrvaluereferences(8.3.2)
yieldxvalues.[Example:Theresultofcallingafunctionwhosereturntypeisanrvaluereferenceto
anobjecttypeisanxvalue(5.2.2).—endexample]
(1.3)—Aglvalue(“generalized”lvalue)isanlvalueoranxvalue.
(1.4)—Anrvalue(socalled,historically,becauservaluescouldappearontheright-handsideofanassignment
expression)isanxvalue,atemporaryobject(12.2)orsubobjectthereof,oravaluethatisnotassociated
withanobject.
(1.5)—Aprvalue(“pure”rvalue)isanrvaluethatisnotanxvalue.[Example:Theresultofcallingafunction
whosereturntypeisnotareferenceisaprvalue.Thevalueofaliteralsuchas12,7.3e5,ortrueis
alsoaprvalue.—endexample]
Everyexpressionbelongstoexactlyoneofthefundamentalclassificationsinthistaxonomy:lvalue,xvalue,
orprvalue.Thispropertyofanexpressioniscalleditsvaluecategory.[Note:Thediscussionofeachbuilt-in
operatorinClause5indicatesthecategoryofthevalueityieldsandthevaluecategoriesoftheoperandsit
expects.Forexample,thebuilt-inassignmentoperatorsexpectthattheleftoperandisanlvalueandthat
therightoperandisaprvalueandyieldanlvalueastheresult.User-definedoperatorsarefunctions,and
thecategoriesofvaluestheyexpectandyieldaredeterminedbytheirparameterandreturntypes.—end
note]
|