Saturday, June 9, 2007

the lifetime of a temporary

Temporary objects are destroyed as the last step in evaluating the full-expression that (lexically) contains the point where they were created.

Two exceptions:

1) An expression used to initialize an object. The temporary that holds the result of the expression shall persist until the object's initialization is complete.

2) A temporary is bound to a reference persists for the lifetime of the reference initialized or until the end of the scope in which the temporary is created, whichever comes first.

No comments: