Boost logo

Boost :

From: Markus Schöpflin (markus.schoepflin_at_[hidden])
Date: 2002-09-30 10:18:12


Gennadiy Rozental wrote:
>
> "Markus Schöpflin" <markus.schoepflin_at_[hidden]> wrote in message
> news:3D98627A.4F937FBB_at_ginit-technology.com...
> > Gennadiy Rozental wrote:
> > >
> > > > The problem is, the temporary object wrapstrstream() is bound to the
> > > > const reference wrapstrstream const& targ which requires an accessible
> > > > copy constructor.
> > > Why?
> >
> > Because of 8.5.3(5) (and vacpp 5 and comeau online) say so.
> >
> > Markus
>
> You have the const reference that is bound to the temporary object. When do
> you need copy constructor?

You have the temporary object created by functional notation (5.2.3) which
is considered an rvalue (3.10(6)). And for rvalues the initilization of the
reference requires the visibility of the copy constructor, because a compiler
is free to create a temporary object as a copy of the rvalue to bind the reference
to.

The standard explicitely says "The constructor that would be used to make the
copy shall be callable whether or not the copy is actually done."

Markus


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk