Comment #0 by john.loughran.colvin — 2015-02-24T18:55:37Z
struct S
{
this(int[3] a){}
}
unittest
{
auto s0 = S([1,2,3]); //OK
import std.conv : emplace;
auto s1 = emplace!S(&s0, [1,2,3]); //Error
}
std/conv.d(4067): Error: static assert "S cannot be emplaced from (int[])."
std/conv.d(4132): instantiated from here: emplaceImpl!(int[])
emplaceTest.d(10): instantiated from here: emplace!(S, int[])
Comment #1 by snarwin+bugzilla — 2024-10-03T22:09:45Z
I'm pretty sure this is impossible. IFTI always infers parameter types from argument types, not the other way around.
The best workaround is probably to use std.array.staticArray to convert the array literal to the correct type:
---
struct S
{
this(int[3] a){}
}
unittest
{
auto s0 = S([1,2,3]); //OK
import std.conv : emplace;
import std.array : staticArray;
auto s1 = emplace!S(&s0, staticArray([1,2,3])); //OK
}
---
Comment #2 by robert.schadek — 2024-12-01T16:23:49Z