[Issue 14222] emplace implicit dynamic to static array fails
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Thu Oct 3 22:09:45 UTC 2024
https://issues.dlang.org/show_bug.cgi?id=14222
Paul Backus <snarwin+bugzilla at gmail.com> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |snarwin+bugzilla at gmail.com
--- Comment #1 from Paul Backus <snarwin+bugzilla at gmail.com> ---
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
}
---
--
More information about the Digitalmars-d-bugs
mailing list