You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[expr.call] says that a parameter's end of lifetime is implementation-defined. But there's an exception for temporary objects in [class.temporary]. Is it worth adding a note about it here? Perhaps there are more exceptions that I'm not aware of, given the way the standard strictly specifies behavior before relaxing elsewhere.
The materialization of a temporary object is generally delayed as long as possible in order to avoid creating unnecessary temporary objects.
[ Note: 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]),
-- https://timsong-cpp.github.io/cppwp/n4861/class.temporary#2.1
5
A reference to type “cv1 T1” is initialized by an expression of type “cv2 T2” as follows:
(5.4)
Otherwise:
(5.4.2)
Otherwise, the initializer expression is implicitly converted to a prvalue of type “cv1 T1”. The temporary materialization conversion is applied and the reference is bound to the result.
-- https://timsong-cpp.github.io/cppwp/n4861/dcl.init.ref#5.4.2
6
The third context is when a reference is bound to a temporary object.35
The temporary object to which the reference is bound or the temporary object that is the complete object of a subobject to which the reference is bound persists for the lifetime of the reference if the glvalue to which the reference is bound was obtained through one of the following:
(6.1)
a temporary materialization conversion ([conv.rval]),
-- https://timsong-cpp.github.io/cppwp/n4861/class.temporary#6.1
The exceptions to this lifetime rule are:
(6.9)
A temporary object bound to a reference parameter in a function call ([expr.call]) persists until the completion of the full-expression containing the call.
-- https://timsong-cpp.github.io/cppwp/n4861/class.temporary#6.9
The text was updated successfully, but these errors were encountered:
It appears to me when the standard specifies it as a temporary object, it shall be ruled by [class.temporary]. Such as
evaluating the prvalue with the temporary object as its result object ...
A parameter object wasn't said so, hence it's not impacted by [class.temporary]. Maybe, the case you referred is that a temporary object is bound to a parameter, where the parameter is a reference and the lifetime of the temporary object is specified by [class.temporary#4].
[expr.call] says that a parameter's end of lifetime is implementation-defined. But there's an exception for temporary objects in [class.temporary]. Is it worth adding a note about it here? Perhaps there are more exceptions that I'm not aware of, given the way the standard strictly specifies behavior before relaxing elsewhere.
And for completeness:
The text was updated successfully, but these errors were encountered: