On 16 Oct, 23:26, "terminator(jam)" <farid.mehr...@gmail.com> wrote:
> A foo(){
> A ret;//this will be return under any conditions.
> //....
> return ret;//pre return :no copy/move};
>
> class A a=foo();//after return : copy/move to a
This is not the case. If the compiler correctly implements NRVO, the
example above will result in a single construction of A using the
default constructor, and then a subsequent destruction. No copies or
moves are made at any point.
---
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ:
http://www.comeaucomputing.com/csc/faq.html ]