$include_dir="/home/hyper-archives/boost/include"; include("$include_dir/msg-header.inc") ?>
From: Greg Colvin (gcolvin_at_[hidden])
Date: 2001-04-06 11:01:18
From: Stephen C. Gilardi <squeegee_at_[hidden]>
> >  > The caveat about temporary smart pointer objects still applies. My rule is
> >  > "never create an unnamed temporary smart pointer." The non-const reference
> >  > idiom tries to enforce this rule... although I have another reason for
> >  > 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 call,
> >so you can't assume much about what's changed. But this case could be seen
> >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?
If f() is declared as
   void f(T&);
then t is not passed by value.
> It seems to me that t was passed by value.  My understanding is that 
> an unnamed temporary of type T is constructed using T's copy 
> constructor and sent to the body of f.  This leaves t completely 
> unmolested.
> 
> If my understanding is incorrect, I'll be very happy to learn what 
> really happens.
> 
> Thanks,
> 
> --Steve
> 
> To unsubscribe, send email to: <mailto:boost-unsubscribe_at_[hidden]>
>  
> 
> Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/ 
> 
> 
>