From: Peter Dimov (pdimov_at_[hidden])
Date: 2001-04-07 07:45:34
From: "Stephen C. Gilardi" <squeegee_at_[hidden]>
> > > The caveat about temporary smart pointer objects still applies. My
> > > "never create an unnamed temporary smart pointer." The non-const
> > > idiom tries to enforce this rule... although I have another reason
> > > preferring pass by non-const reference:
> > >
> >> void f(T arg);
> > >
> > > T t;
> >> f(t);
> > >
> > > // now t is unchanged, right?
> >Wrong, of course. Usually, the declaration of f isn't visible near the
> >so you can't assume much about what's changed. But this case could be
> >as an argument for using the unnamed temporary... then there's no object
> >hanging around with a confusing value.
> I don't see how t's value could be changed in the above example.
> Could you please explain?
My point exactly. Pass by value is supposed not to modify the passed object.
But, when T is std::auto_ptr, it does, changing the meaning of a built-in
language construct (pass by value) to do something "cooler."
-- Peter Dimov Multi Media Ltd.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk