From: Brian McNamara (lorgon_at_[hidden])
Date: 2004-02-08 14:31:39
On Sun, Feb 08, 2004 at 11:39:51AM -0500, David Abrahams wrote:
> Brian McNamara <lorgon_at_[hidden]> writes:
> > David Abrahams writes:
> >> 12.2/1 says that the act of binding an rvalue to a (const) reference
> >> creates a temporary (which may be elided). The creation of the
> >> temporary requires the existence of a copy ctor with a const&
> >> argument. As far as I know, that rule serves no useful purpose, but I
> >> may have missed something.
> > I am not sure what portion of the rule you don't like. Is it the fact
> > that they point to a particular copy constructor (the const& one),
> > rather than just any available/visible/something copy constructor?
> No, it's the fact that any additional temporary at all (and thus, a
> copy ctor) is needed.
> > In test10, what do you 'want' to happen here:
> > sink2( <a temporary object, that is, an rvalue> );
> It should bind a const reference to the temporary without complaining
> that the temporary can't be copied.
I see. What about
const X& x = source(); // 12.2/5
? Or something. I am trying to find the 'hard' cases where the
compiler might not be able to easily make the temporary have the right
'lifetime', and thus require an extra copy.
My guess is that the only reason that rule exists is that it somehow
makes compiler writers' lives easier, so my hunch is you'll need to
talk to (argue with :) ) them.
-- -Brian McNamara (lorgon_at_[hidden])
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk