return

Allan Sandfeld Jensen kde-optimize@mail.kde.org
Mon, 3 Feb 2003 17:11:53 +0100


On Monday 03 February 2003 14:30, David Leimbach wrote:
> Basically you can have named or unnamed RVO [return value
> optimization].  I am not sure its really a big deal with this example
> since you use a built-in, simple type like bool.  If these were objects
> that used constructors then
> RVO becomes a lot more important due to the need to copy-construct and
> default construct  objects.  Neither of those  really happen in your
> example so to me it seems either way is fine.
>
<SNIP>
>
> Sometimes a named return value won't get optimized by some compilers...
> I don't know if that
> is the case with gcc or not.
>
> The authors also claim that you must define a copy constructor to "turn
> on" RVO.
>
gcc has an extention that enables you to write:

Complex operator + (const Complex & a, const Complex & b) return retval
{
   retVal.real = a.real + b.real;
   retVal.imag = a.imag + b.imag;
}


I think it is meant to force this optimization, do you know anything about it?

`Alln