On Tuesday, 10 July 2018 at 18:01:59 UTC, Steven Schveighoffer
You are overthinking :) inout typically is much easier than you
expect, until you need to create temporary structs or types
with inout members, then it becomes problematic.
I had to put in a static if, because your function doesn't work
once you get down to the array type. See the // fixme comment.
Ok, well that helped a tiny bit for the example.
I'm trying to reproduce the errors from my project. It's starting
to get out of control : D. inout is on a rampage!
I guess it's the same as for immutable initialization of arrays.
I can't seem to find a proper response to this one..
inout(I) opIndex(size_t idx) inout;
class Test(T) : I
this(inout T mem) inout
this.member = mem;
inout(Test!T) get() inout
return new inout Test!(Unqual!(typeof(member)))(member);
inout(I) opIndex(size_t idx) inout
static if (is(T == struct))
static foreach (index, t; T.tupleof)
return new inout
auto test(T)(inout T t)
return new inout Test!(Unqual!T)(t);
class TestA(T : T)
// ERROR: Can't initialize inout variable in a
this(inout(T) arr) inout
// 1: Nope
foreach (mem; arr)
this.arr ~= test(mem);
// 2: Nope
//foreach (mem; arr)
// a ~= test(mem);
import std.algorithm : map;
// 3: Nope
// this.arr = arr.map!((e) => test(e)).array;
auto ss = SS(S([1,2,3]));
auto t = new const Test!SS(ss);
auto ta = new const TestA!(Test!SS)([t]);