Re: What's going on here?!
From: Tom Widmer (tom_usenet_at_hotmail.com)
Date: 02/01/05
- Next message: William DePalo [MVP VC++]: "Re: Modeless Dialogs and WM_CHAR"
- Previous message: Callum Winter: "Re: Modeless Dialogs and WM_CHAR"
- In reply to: BigMan: "Re: What's going on here?!"
- Next in thread: Doug Harrison [MVP]: "Re: What's going on here?!"
- Messages sorted by: [ date ] [ thread ]
Date: Tue, 01 Feb 2005 14:27:16 +0000
BigMan wrote:
> Thanks, Tom!
> Now I see... and it sound very strange that the standard allows a copy of
> the rvalue to be created.
> So, can anyone tell me why the standard allows a copy of the rvalue to be
> created instead of just binding the reference to the rvalue.
I think it's because of the lifetime extension properties of const
references. e.g.
Foo makeFoo();
Foo const& f = makeFoo(); //temporary lasts as long as f.
The compiler might require the temporary to be copied into a particular
area of the stack in order that it persist until f goes out of scope.
However, because this only potential need only arises when the lifetime
of a temporary is extended, it has been suggested that the standard
change to say that a copy won't be made in the case where the temporary
will only last until the end of the full expression in which it is
created. See:
http://groups-beta.google.com/group/comp.std.c++/msg/6700d973aedf00fc
Tom
- Next message: William DePalo [MVP VC++]: "Re: Modeless Dialogs and WM_CHAR"
- Previous message: Callum Winter: "Re: Modeless Dialogs and WM_CHAR"
- In reply to: BigMan: "Re: What's going on here?!"
- Next in thread: Doug Harrison [MVP]: "Re: What's going on here?!"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|