$include_dir="/home/hyper-archives/boost/include"; include("$include_dir/msg-header.inc") ?>
From: Peter Dimov (pdimov_at_[hidden])
Date: 2002-07-03 05:46:35
From: "Yitzhak Sapir" <yitzhaks_at_[hidden]>
> I had to view Daniel Frey's mail as an attachment, but from reading it I
have a question:
>
> He suggested:
> > friend const T operator+( const T& lhs, const T& rhs )
> > {
> > T nrv( lhs );
> > nrv += rhs;
> > return nrv;
> > }
>
> Why not use:
>
> friend const T operator+ (const T& lhs, const T& rhs)
> {
> return T(lhs) += rhs;
> }
>
> doing away with the named temporary, and possibly using normal return
value optimization?
Because this assumes that the compiler knows that T::operator+= returns
*this.