[Issue 12628] emplace does not work for rvalues

via Digitalmars-d-bugs digitalmars-d-bugs at puremagic.com
Wed Apr 23 23:24:28 PDT 2014


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

monarchdodra at gmail.com changed:

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

--- Comment #1 from monarchdodra at 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...

--


More information about the Digitalmars-d-bugs mailing list