In the following example `inout` constructor works for some types but fails for others.
test.d:
--------------------
struct Foo(T)
{
T[1] a;
this(in T[] src) inout { a = src; } // <----- line 4
}
enum fbool = Foo!bool([true]); // OK
enum fint = Foo!int([1]); // OK
enum flong = Foo!long([1]); // OK
enum fchar = Foo!char(['1']); // OK
enum fstring = Foo!string(["1"]); // Error
enum ffloat = Foo!float([1]); // Error
struct Boo { int a; }
enum fstruct = Foo!Boo([Boo(1)]); // Error
void main() {}
--------------------
Output:
--------------------
test.d(4): Error: array cast from const(string[]) to const(inout(string)[]) is not supported at compile time
test.d(12): called from here: Foo(null).this(["1"])
test.d(4): Error: array cast from const(float[]) to const(inout(float)[]) is not supported at compile time
test.d(13): called from here: Foo(nanF).this([1.00000F])
test.d(4): Error: array cast from const(Boo[]) to const(inout(Boo)[]) is not supported at compile time
test.d(15): called from here: Foo(Boo(0)).this([Boo(1)])
--------------------
Comment #1 by robert.schadek — 2024-12-13T18:42:11Z