Bug 12628 – emplace does not work for rvalues

Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P1
Component
phobos
Product
D
Version
D2
Platform
All
OS
All
Creation time
2014-04-23T19:43:47Z
Last change time
2021-08-04T20:50:14Z
Assigned to
No Owner
Creator
Andrei Alexandrescu

Comments

Comment #0 by andrei — 2014-04-23T19:43:47Z
Consider: #!/Users/aalexandre/bin/rdcc import std.conv, std.stdio; struct A { A* next; bool b; @disable this(this); } struct B { A a; } void main() { A a; emplace(&a, A(null, false)); B b; emplace(&b, A()); } Both calls fail to compile. These calls to emplace should work because they don't need to postblit stuff around - they could just move from the rvalues received.
Comment #1 by monarchdodra — 2014-04-24T06:24:28Z
(In reply to Andrei Alexandrescu from comment #0) > Consider: > > #!/Users/aalexandre/bin/rdcc > import std.conv, std.stdio; > > struct A > { > A* next; > bool b; > @disable this(this); > } > > struct B > { > A a; > } > > void main() > { > A a; > emplace(&a, A(null, false));we > B b; > emplace(&b, A()); > } > > Both calls fail to compile. These calls to emplace should work because they > don't need to postblit stuff around - they could just move from the rvalues > received. Hum... looks like you are asking for emplace to know how to elide postblit... It *should* be doable, but it's kind of hard: I'll try to look into making it work. It's necessary for making it function with "opCall()" anyways. In the meantime, you could just: emplace(&a, null, false); //emplace from args emplace(&b); //construct by default I'll look into making it work. First case should be "easy-ish". The second seems harder...
Comment #2 by monarchdodra — 2014-04-30T09:38:46Z
Not mandatory, but would be quite helpful, this needs fixing first: https://issues.dlang.org/show_bug.cgi?id=12684
Comment #3 by andrei — 2014-04-30T16:42:45Z
(In reply to monarchdodra from comment #2) > Not mandatory, but would be quite helpful, this needs fixing first: > https://issues.dlang.org/show_bug.cgi?id=12684 Yah, they kinda go together.
Comment #4 by kinke — 2021-08-04T20:50:14Z
Works since v2.096 - see https://issues.dlang.org/show_bug.cgi?id=17415, which was most likely a duplicate of this.