[Issue 15313] New: std.conv.emplace cannot initialize const objects
via Digitalmars-d-bugs
digitalmars-d-bugs at puremagic.com
Tue Nov 10 04:26:52 PST 2015
https://issues.dlang.org/show_bug.cgi?id=15313
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 at puremagic.com
Reporter: andrei at 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
message.
--
More information about the Digitalmars-d-bugs
mailing list