www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 20468] New: emplace doesn't forward constructor arguments'

https://issues.dlang.org/show_bug.cgi?id=20468

          Issue ID: 20468
           Summary: emplace doesn't forward constructor arguments'
                    (l/r)valueness
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: normal
          Priority: P1
         Component: druntime
          Assignee: nobody puremagic.com
          Reporter: sahmi.soulaimane gmail.com

`core.lifetime.emplace` always forwards constructor arguments by ref.

example:
```
import core.lifetime : emplace;
import std.stdio;
struct A {}
struct B
{
    this()(auto ref A a)
    {
        static if (__traits(isRef, a))
            writeln("copy");
                else
            writeln("move");
    }
}
void main()
{
    B obj = void;
    A a;
    emplace(&obj, a);
    emplace(&obj, A());
}
```

output:
---
copy
copy
---

expected output:
---
copy
move
---

--
Dec 27 2019