Re: How to get an inout constructor working with a template wrapper

2018-07-31 Thread aliak via Digitalmars-d-learn
On Tuesday, 31 July 2018 at 21:54:54 UTC, Steven Schveighoffer wrote: Because inout is trying to combine all mutability modifiers into one. You want to specify the type, not the mutability, in the template parameter T. Ahhh. Ok I see... I think. This doesn't make sense. Can you post runnable

Re: How to get an inout constructor working with a template wrapper

2018-07-31 Thread Steven Schveighoffer via Digitalmars-d-learn
On 7/31/18 5:29 PM, aliak wrote: On Tuesday, 31 July 2018 at 12:37:34 UTC, Steven Schveighoffer wrote: On 7/29/18 1:46 PM, aliak wrote: On Sunday, 29 July 2018 at 12:45:48 UTC, Steven Schveighoffer wrote: Am I applying inout incorrectly? No, you need to apply it to wrap as well. I can't get

Re: How to get an inout constructor working with a template wrapper

2018-07-31 Thread aliak via Digitalmars-d-learn
On Tuesday, 31 July 2018 at 12:37:34 UTC, Steven Schveighoffer wrote: On 7/29/18 1:46 PM, aliak wrote: On Sunday, 29 July 2018 at 12:45:48 UTC, Steven Schveighoffer wrote: Am I applying inout incorrectly? No, you need to apply it to wrap as well. I can't get run.dlang.io to work for posting

Re: How to get an inout constructor working with a template wrapper

2018-07-31 Thread Steven Schveighoffer via Digitalmars-d-learn
On 7/29/18 1:46 PM, aliak wrote: On Sunday, 29 July 2018 at 12:45:48 UTC, Steven Schveighoffer wrote: Am I applying inout incorrectly? No, you need to apply it to wrap as well. I can't get run.dlang.io to work for posting a link, so here is my modified version: Ah bugger, right! Ok so t

Re: How to get an inout constructor working with a template wrapper

2018-07-29 Thread aliak via Digitalmars-d-learn
On Sunday, 29 July 2018 at 12:45:48 UTC, Steven Schveighoffer wrote: Am I applying inout incorrectly? No, you need to apply it to wrap as well. I can't get run.dlang.io to work for posting a link, so here is my modified version: Ah bugger, right! Ok so there's no way to make explicit in

Re: How to get an inout constructor working with a template wrapper

2018-07-29 Thread Steven Schveighoffer via Digitalmars-d-learn
On 7/28/18 6:09 PM, aliak wrote: On Friday, 27 July 2018 at 14:38:27 UTC, Steven Schveighoffer wrote: On 7/27/18 9:29 AM, aliak wrote: Ok, thanks to Simen from another post [0], I just figured out what the correct constructor and factory method for a template wrapper should be: https://run.d

Re: How to get an inout constructor working with a template wrapper

2018-07-28 Thread aliak via Digitalmars-d-learn
On Friday, 27 July 2018 at 14:34:54 UTC, Steven Schveighoffer wrote: The problem here is that inout(immutable(int)) is equivalent to immutable(int). That is, all flavors of mutability are equivalent to immutable(int): /*mutable*/(immutable(int)) => immutable(int) const(immutable(int))

Re: How to get an inout constructor working with a template wrapper

2018-07-28 Thread aliak via Digitalmars-d-learn
On Friday, 27 July 2018 at 14:38:27 UTC, Steven Schveighoffer wrote: On 7/27/18 9:29 AM, aliak wrote: Ok, thanks to Simen from another post [0], I just figured out what the correct constructor and factory method for a template wrapper should be: https://run.dlang.io/is/S4vHzL struct W(T) {

Re: How to get an inout constructor working with a template wrapper

2018-07-27 Thread Steven Schveighoffer via Digitalmars-d-learn
On 7/27/18 9:29 AM, aliak wrote: Ok, thanks to Simen from another post [0], I just figured out what the correct constructor and factory method for a template wrapper should be: https://run.dlang.io/is/S4vHzL struct W(T) {     T val;     this(U : T, this This)(auto ref U val) {     this.

Re: How to get an inout constructor working with a template wrapper

2018-07-27 Thread Steven Schveighoffer via Digitalmars-d-learn
On 7/23/18 8:02 AM, aliak wrote: On Sunday, 22 July 2018 at 23:11:09 UTC, Ali Çehreli wrote: Without much confidence on my side, first, I think you need to make the constructor parameter inout(T) as well. Otherwise, you may be making a const(W!T) initialized with a non-const T. After that, I

Re: How to get an inout constructor working with a template wrapper

2018-07-27 Thread aliak via Digitalmars-d-learn
On Monday, 23 July 2018 at 14:46:32 UTC, Timoses wrote: On Monday, 23 July 2018 at 12:02:58 UTC, aliak wrote: [...] Both of these seem to work (as you pointed out) // immutable(W!int) auto si = wrap!(int)(cast(immutable)3); // or wrap(cast(immutable)3); // W!(immutable(int))

Re: How to get an inout constructor working with a template wrapper

2018-07-23 Thread Timoses via Digitalmars-d-learn
On Monday, 23 July 2018 at 12:02:58 UTC, aliak wrote: Thank you Ali! That helped :) I've gotten most of it sorted out now, and the factory wrap is definitely the way to go, it also turned out that inout(T) and inout T (so inout without parens) was surprisingly different (maybe it's a bug? - t

Re: How to get an inout constructor working with a template wrapper

2018-07-23 Thread aliak via Digitalmars-d-learn
On Monday, 23 July 2018 at 12:02:58 UTC, aliak wrote: https://run.dlang.io/is/gd5oxW Sorry wrong link! This one is correct -> https://run.dlang.io/is/azxmGN

Re: How to get an inout constructor working with a template wrapper

2018-07-23 Thread aliak via Digitalmars-d-learn
On Sunday, 22 July 2018 at 23:11:09 UTC, Ali Çehreli wrote: Without much confidence on my side, first, I think you need to make the constructor parameter inout(T) as well. Otherwise, you may be making a const(W!T) initialized with a non-const T. After that, I like the "type constructor" syntax

Re: How to get an inout constructor working with a template wrapper

2018-07-22 Thread Ali Çehreli via Digitalmars-d-learn
On 07/22/2018 03:51 PM, aliak wrote: > Hi, > > In the code below: > > struct W(T) { > T val; > this(T val) inout { > this.val = val; > } > } > > class C {} > > void main() { > W!C a = new C; > immutable W!C b = new C; > } > > W!C a = new C results in: "Error: cannot