[Issue 17415] New: std.conv.emplace does not forward arguments correctly

via Digitalmars-d-bugs digitalmars-d-bugs at puremagic.com
Sat May 20 16:04:45 PDT 2017


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

          Issue ID: 17415
           Summary: std.conv.emplace does not forward arguments correctly
           Product: D
           Version: D2
          Hardware: x86_64
                OS: All
            Status: NEW
          Severity: major
          Priority: P1
         Component: phobos
          Assignee: nobody at puremagic.com
          Reporter: stanislav.blinov at gmail.com

import std.conv : emplace;

struct S
{
    @disable this(this);
}

class C
{
    this(S) {}
}

void[__traits(classInstanceSize, C)] holder = 0;
emplace!C(S.init);

I'd expect that to compile, and move the initializer correctly. But it does not
compile (static assert), because emplace() copies arguments around, instead of
using something like std.functional.forward. However, the fix is not trivial,
some of the Phobos code actually depends on this, whether intentionally or
accidentally, I cannot tell.

--


More information about the Digitalmars-d-bugs mailing list