问题
[class.temporary]/2
The materialization of a temporary object is generally delayed as long as possible in order to avoid creating unnecessary temporary objects.
[Note 3: Temporary objects are materialized:
(2.1) when binding a reference to a prvalue ([dcl.init.ref], [expr.type.conv], [expr.dynamic.cast], [expr.static.cast], [expr.const.cast], [expr.cast]),
(2.2) when performing member access on a class prvalue ([expr.ref], [expr.mptr.oper]),
(2.3) when performing an array-to-pointer conversion or subscripting on an array prvalue ([conv.array], [expr.sub]),
(2.4)
when initializing an object of type std::initializer_list<T>
from a braced-init-list ([dcl.init.list]),
(2.5) for certain unevaluated operands ([expr.typeid], [expr.sizeof]), and
(2.6)
when a prvalue that has type other than cv void
appears as a discarded-value expression ([expr.prop]).
— end note]
回答1:
The referenced sections ([dcl.init.ref] etc.) have normative wording that specifies exactly when temporary materialization occurs. This note exists only as a quick reference so you don't have to look through the whole standard to find all the situations where temporary materialization happens. If it were normative, then it would be redundant at best, and conflicting at worst. Making it non-normative preserves its usefulness while avoiding any potential issues.
来源:https://stackoverflow.com/questions/65568827/why-the-note-3-in-class-temporary-2-shouldnt-paragraphs-2-1-thru-2-6-hav