From section 12.2.3 of the C ++ 2003 standard (draft)
Temporary objects are destroyed as the last step in evaluating the full expression (1.9), which (lexically) contains the point at which they were created.
ยง 12.2.4:
There are two contexts in which temporary objects are destroyed at another point, the expression ....
ยง 12.2.5:
- . , , , , , .... (5.2.2) , .
ยง8.5.3.5 - , , const-. , , , ( ). :
class Foo {
...
operator Bar&() const;
...
void baz(Bar &b);
...
baz(Foo());
baz(Bar());
- ยง 12.3.2.1, : " [...] [...] (
) ". , , Bar .
- (ยง 5.17), (ยง 1.9.12) . ( , , , ):
string& text erase_whitespaceerase_whitespace .erase_whitespacestring text- .
, . , , erase_whitespace . , , , , , , , , . - , ...