Afficher un message
Vieux 17/10/2007, 18h53   #3
int19h@gmail.com
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: pre return optimization

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 ]

  Réponse avec citation
 
Page generated in 0,04434 seconds with 9 queries