Why the Note 3 in [class.temporary]/2? Shouldn't paragraphs (2.1) thru (2.6) have normative status?

☆樱花仙子☆ 提交于 2021-01-07 01:18:10

问题


[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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!