Thread overview
[Issue 12628] emplace does not work for rvalues
Aug 04, 2021
kinke
April 24, 2014
https://issues.dlang.org/show_bug.cgi?id=12628

monarchdodra@gmail.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |monarchdodra@gmail.com
           Hardware|x86                         |All
                 OS|Mac OS X                    |All

--- Comment #1 from monarchdodra@gmail.com ---
(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...

--
April 30, 2014
https://issues.dlang.org/show_bug.cgi?id=12628

--- Comment #2 from monarchdodra@gmail.com ---
Not mandatory, but would be quite helpful, this needs fixing first: https://issues.dlang.org/show_bug.cgi?id=12684

--
April 30, 2014
https://issues.dlang.org/show_bug.cgi?id=12628

--- Comment #3 from Andrei Alexandrescu <andrei@erdani.com> ---
(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.

--
June 09, 2015
https://issues.dlang.org/show_bug.cgi?id=12628

Andrei Alexandrescu <andrei@erdani.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Version|unspecified                 |D2

--
August 04, 2021
https://issues.dlang.org/show_bug.cgi?id=12628

kinke <kinke@gmx.net> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |kinke@gmx.net
         Resolution|---                         |FIXED

--- Comment #4 from kinke <kinke@gmx.net> ---
Works since v2.096 - see https://issues.dlang.org/show_bug.cgi?id=17415, which was most likely a duplicate of this.

--