On Tuesday, 17 August 2021 at 18:27:21 UTC, Steven Schveighoffer
wrote:
According to my tests, it prefers the `T` version over the
static array version. Which leads me to believe that it prefers
a dynamic array over a static one. In fact, if I comment out
the `T` version, it doesn't compile. It literally will not pick
that specialization, even if it can interpret the literal that
way.
which is really bizarre, since if you do it without
specializations, but just spelling out all the template
components (as in your alternative workaround), it WILL pick
that one over a dynamic array one.
Oh my, that's weird... Not meant to bash but given all I've seen
of argument deduction & templates & specializations... I think
the implementation needs some serious rework 😅
---
Interestingly enough my approach will not even work for 2d array
literals. It will manage going to int[][2], but int[2][2] is one
step too far. Which is a real bummer. :(
That is, it won't figure it out itself, but when you call `foo(T,
uintL)(T[L][L]...` using an explicit `foo!(int, 2)` it _will_
work. Even though it manages T[L] just fine.
Meanwhile T[2][L] _and_ T[L][2] won't work when called with a 2x2
array literal.