c++ - Does a reference declaration introduce a new name for the referent? -


in this question we've learnt rvo cannot applied expression p.first.

in comments suggested rvo not applied expression r after declaration auto& r = p.first. less clear whether standard mandates behaviour.

in return statement in function class return type, when expression name of non-volatile automatic object (other function parameter or variable introduced exception-declaration of handler ([except.handle])) same type (ignoring cv-qualification) function return type, copy/move operation can omitted constructing automatic object directly function's return value

in following code, r name of object known o, extent rvo permissible when forms expression in return statement?

int o = 42; int& r = o; 

cwg #633 addressed fact references, unlike objects, didn't have actual names. resolved n2993, extended notion of variable encompass references, thereby giving them names.
[basic]/6 reads (all emphasis me):

a variable introduced declaration of reference other non-static data member or of object. the variable's name denotes object or reference.

the name of reference denotes variable - reference - not object reference refers to. although references commonly explained being "other names of objects/functions", in standard terms definition plain wrong.

i.e. copy elision not applicable in example.


since above paper not adopted until 2009, , tagged : 1 can consider paper retrospective correction of c++03. however, in c++03, strictly speaking, reference not entity (this rectified cwg #485) , therefore identifier in declaration never treated name (see [basic]/4, name must denote label or entity) - hence copy elision doesn't apply, again.


Comments

Popular posts from this blog

javascript - Chart.js (Radar Chart) different scaleLineColor for each scaleLine -

apache - Error with PHP mail(): Multiple or malformed newlines found in additional_header -

java - Android – MapFragment overlay button shadow, just like MyLocation button -