[Issue 20468] New: emplace doesn't forward constructor arguments' (l/r)valueness
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Sat Dec 28 02:35:35 UTC 2019
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 at puremagic.com
Reporter: sahmi.soulaimane at 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
---
--
More information about the Digitalmars-d-bugs
mailing list