www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 15313] New: std.conv.emplace cannot initialize const objects


          Issue ID: 15313
           Summary: std.conv.emplace cannot initialize const objects
           Product: D
           Version: D2
          Hardware: All
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P1
         Component: phobos
          Assignee: nobody puremagic.com
          Reporter: andrei erdani.com

Consider this code:

struct Node
    int payload;
    Node* next;
    uint refs;

void main()
    import core.stdc.stdlib : malloc;
    void[] buf = malloc(Node.sizeof)[0 .. Node.sizeof];
    import std.conv : emplace;
    const Node* n = emplace!(Node)(buf, 42, null, 10);

Essentially the attempt is to create a new const Node object in the specified
buffer. The code should work, but fails to compile with an obscure error

Nov 10 2015