[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Copy constructor at return
From: |
Alan Woodland |
Subject: |
Re: Copy constructor at return |
Date: |
Fri, 22 Sep 2006 11:06:47 +0100 |
User-agent: |
Debian Thunderbird 1.0.2 (X11/20060830) |
Igor.Smirnov@cern.ch wrote:
> Hi,
>
> Why g++ in Linux does not call copy constructor at return statement?
>
It's known as return value optimization. See:
http://www.parashift.com/c++-faq-lite/ctors.html#faq-10.9 for more
details. Basically though you can't rely upon any side effects of copy
constructors (which in your case was the output), since compilers aren't
required to make an instance and then copy it.
Alan