[Issue 19904] move semantics fail through the `emplace` pipeline
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Mon May 27 20:24:14 UTC 2019
https://issues.dlang.org/show_bug.cgi?id=19904
--- Comment #2 from kinke at gmx.net ---
This is what I mean:
import core.stdc.stdio;
struct S
{
this(this) { printf("postblit\n"); }
~this() { printf("dtor\n"); }
}
void foo(S s) { printf("rvalue\n"); }
void foo(ref S s) { printf("lvalue\n"); }
void forward(Args...)(auto ref Args args) { foo(args); }
void main()
{
printf("directly:\n");
foo(S());
printf("forward:\n");
forward(S());
}
=>
directly:
rvalue
dtor
forward:
lvalue
dtor
The rvalue-ness is lost when forwarding `auto ref` params this way (but still
detectible via isRef trait).
--
More information about the Digitalmars-d-bugs
mailing list