On 03/10/18 04:10, Walter Bright wrote:
On 10/2/2018 4:30 PM, Adam D. Ruppe wrote:
On Tuesday, 2 October 2018 at 22:30:38 UTC, Jonathan M Davis wrote:
Yeah. IIRC, it was supposed to be _guaranteed_ that the compiler moved structs in a number of situations - e.g. when the return value was an rvalue. Something like

Eh, I don't think that moves it, but rather just constructs it in-place for the next call.

The technical term for that is "copy elision".

I'm not sure I follow.

First of all, you cannot elide the copy if there is more than one potential local variable you are returning, ala:

A someFunc() {
  A a, b;
  manipulate(a); manipulate(b);

  if( someRandomCondition )
    return a;

  return b;
}

What happens then?

What happens if A has @disable this(this)?

What happens if we explicitly call std.algorithm.move?

Shachar

Reply via email to