Thread overview
[Issue 14222] emplace implicit dynamic to static array fails
Jul 05, 2017
Vladimir Panteleev
Jul 05, 2017
Vladimir Panteleev
Dec 17, 2022
Iain Buclaw
July 05, 2017
https://issues.dlang.org/show_bug.cgi?id=14222

Vladimir Panteleev <dlang-bugzilla@thecybershadow.net> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |dlang-bugzilla@thecybershad
                   |                            |ow.net

--
July 05, 2017
https://issues.dlang.org/show_bug.cgi?id=14222

Vladimir Panteleev <dlang-bugzilla@thecybershadow.net> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|dlang-bugzilla@thecybershad |
                   |ow.net                      |

--
December 17, 2022
https://issues.dlang.org/show_bug.cgi?id=14222

Iain Buclaw <ibuclaw@gdcproject.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Priority|P1                          |P3

--
October 03
https://issues.dlang.org/show_bug.cgi?id=14222

Paul Backus <snarwin+bugzilla@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |snarwin+bugzilla@gmail.com

--- Comment #1 from Paul Backus <snarwin+bugzilla@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
}
---

--