Re: Troubles creating templated inout objects

2018-07-12 Thread Timoses via Digitalmars-d-learn
On Thursday, 12 July 2018 at 12:22:34 UTC, Steven Schveighoffer wrote: On 7/11/18 8:55 AM, Timoses wrote: class TestA(T : T[]) {     Test!T[] arr;     // ERROR: Can't initialize inout variable in a for loop...     this(inout(T[]) arr) inout     {    

Re: Troubles creating templated inout objects

2018-07-12 Thread Steven Schveighoffer via Digitalmars-d-learn
On 7/12/18 4:58 AM, Timoses wrote: On Tuesday, 10 July 2018 at 14:34:55 UTC, Timoses wrote: `Unqual` in this case just turns `inout(int[])` into `inout(int)[]`, which is why it complains. That's a side effect of this example [...] See also: https://issues.dlang.org/show_bug.cgi?id=3567

Re: Troubles creating templated inout objects

2018-07-12 Thread Steven Schveighoffer via Digitalmars-d-learn
On 7/11/18 8:55 AM, Timoses wrote: On Tuesday, 10 July 2018 at 18:01:59 UTC, Steven Schveighoffer wrote: 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.

Re: Troubles creating templated inout objects

2018-07-12 Thread Timoses via Digitalmars-d-learn
On Tuesday, 10 July 2018 at 14:34:55 UTC, Timoses wrote: `Unqual` in this case just turns `inout(int[])` into `inout(int)[]`, which is why it complains. That's a side effect of this example [...] See also: https://issues.dlang.org/show_bug.cgi?id=3567

Re: Troubles creating templated inout objects

2018-07-12 Thread Timoses via Digitalmars-d-learn
On Wednesday, 11 July 2018 at 12:55:35 UTC, Timoses wrote: On Tuesday, 10 July 2018 at 18:01:59 UTC, Steven Schveighoffer wrote: 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

Re: Troubles creating templated inout objects

2018-07-11 Thread Timoses via Digitalmars-d-learn
On Tuesday, 10 July 2018 at 18:01:59 UTC, Steven Schveighoffer wrote: 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. https://run.dlang.io/is/kosYuC I had to put in a

Re: Troubles creating templated inout objects

2018-07-10 Thread Steven Schveighoffer via Digitalmars-d-learn
On 7/10/18 10:34 AM, Timoses wrote: How do I create an inout object with template parameters? Take following code: import std.stdio; import std.traits; struct S {     int[] arr; } interface I {     inout(I) opIndex(size_t idx) inout; }

Troubles creating templated inout objects

2018-07-10 Thread Timoses via Digitalmars-d-learn
How do I create an inout object with template parameters? Take following code: import std.stdio; import std.traits; struct S { int[] arr; } interface I { inout(I) opIndex(size_t idx) inout; }