From 5310082004608486487
X-Google-Thread: f78e5,bd52daa8ac2e51f1
X-Google-Thread: 109fba,bd52daa8ac2e51f1
X-Google-Attributes: gidf78e5,gid109fba,public,usenet
X-Google-Language: ENGLISH,ASCII-7-bit
Path: g2news2.google.com!news1.google.com!news.glorb.com!news.alt.net!comp-std-cpp-robomod!not-for-mail
From: int19h@gmail.com
Newsgroups: comp.std.c++,comp.lang.c++
Subject: Re: pre return optimization
Date: Wed, 17 Oct 2007 11:53:54 CST
Organization: http://groups.google.com
Lines: 19
Approved: Fergus Henderson <fjh@cs.mu.oz.au>, moderator of comp.std.c++
Message-ID: <1192594314.094118.106830@q5g2000prf.googlegroups.com>
References: <1191919832.635392.256930@d55g2000hsg.googlegroups.com>
   <1192280210.586133.256780@e34g2000pro.googlegroups.com>
   <1192533980.713544.27090@e34g2000pro.googlegroups.com>
Mime-Version: 1.0
Content-Type: text/plain; charset="us-ascii"
X-Trace: posting.google.com 1192594314 26743 127.0.0.1 (17 Oct 2007 04:11:54 GMT)
X-Complaints-To: groups-abuse@google.com
NNTP-Posting-Date: Wed, 17 Oct 2007 04:11:54 +0000 (UTC)
Return-Path: <devnull@stump.algebra.com>
X-Authentication-Warning: mulga.csse.unimelb.edu.au: fjh set sender to devnull@stump.algebra.com using -f
X-Robomod: STUMP, ichudov@algebra.com (Igor Chudov)
X-Original-To: std-c++@mailman.ucar.edu
Delivered-To: std-c++@mailman.ucar.edu
X-SMTP-Auth: no
User-Agent: G2/1.0
X-HTTP-UserAgent: Opera/9.22 (Windows NT 5.1; U; en),gzip(gfe),gzip(gfe)
Complaints-To: groups-abuse@google.com
Injection-Info: q5g2000prf.googlegroups.com; posting-host=85.140.22.182;
   posting-account=ps2QrAMAAAA6_jCuRt2JEIpn5Otqf_w0
X-Virus-Scanned: amavisd-new at ucar.edu
X-Virus-Scanned: amavisd-new at csse.unimelb.edu.au
X-Virus-Scanned: amavisd-new at csse.unimelb.edu.au
Xref: g2news2.google.com comp.std.c++:868 comp.lang.c++:22973

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                      ]



