Copy elision by spec

Lars T. Kyllingstad public at kyllingen.net
Mon Nov 4 03:41:03 PST 2013


On Monday, 4 November 2013 at 07:17:12 UTC, monarch_dodra wrote:
> http://d.puremagic.com/issues/show_bug.cgi?id=11287
>
> According to the conversation, NRVO is supposed to be part of 
> the spec, and you should expect it to work.

I'm not an expert, but aren't there cases where NRVO can't be 
applied?  For example:

   S foo()
   {
      S s1;
      // Initialize s1
      S s2;
      // Initialize s2
      if (someCondition) return s1;
      else return s2;
   }

However, the return value can always be *moved*.


More information about the Digitalmars-d mailing list