引用声明是否为引用者引入了一个新名称?

Does a reference declaration introduce a new name for the referent?

中我们了解到 RVO 不能应用于像 p.first.

这样的表达式

在评论中还建议 RVO 通常不应用于像 auto& r = p.first 这样的声明之后的像 r 这样的表达式。不太清楚标准是否强制要求这种行为。

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

在下面的代码中,r是对象的名称,也称为o,在RVO形成时允许的范围内return 语句中的表达式?

int o = 42;
int& r = o;

CWG #633 addressed the fact that references, unlike objects, didn't have actual names. It was resolved by N2993,它扩展了变量的概念以包含引用,从而为它们命名。
现在 [basic]/6 阅读(都是我强调的):

A variable is introduced by the declaration of a reference other than a non-static data member or of an object. The variable's name denotes the object or reference.

引用的名称表示该变量 - 引用 - 而不是引用所指的对象。尽管引用通常被解释为 "other names of objects/functions",但在标准术语中,该定义是完全错误的。

即复制省略不适用于您的示例。


由于上述论文直到 2009 年才被采纳,并且您标记了 : One can consider the paper as a retrospective correction of C++03. However, in C++03, strictly speaking, a reference is not an entity (this was rectified by CWG #485),因此其声明中的标识符永远不会被视为名称(参见 [basic]/4,名称必须表示标签或实体)- 因此复制省略再次不适用。