How to avoid inout type constructor with Optional type wrapper undoing string type

aliak something at something.com
Mon Jul 23 19:31:42 UTC 2018


On Monday, 23 July 2018 at 19:22:13 UTC, aliak wrote:
> On Monday, 23 July 2018 at 19:02:02 UTC, Jacob Carlborg wrote:
>>
>> This [1] compiles the first example but not the second.
>>
>> [1] https://run.dlang.io/is/SJ02kP
>
> Aye it does, but it also sets T to always const which is 
> unfortunately impractical for my use case :(

Ok, now I'm totally confused. Defining an extra type constructor 
makes everything work. I.e add a const one to the inout one:

auto defined(T)(const auto ref T value) {
     return W!T(value);
}

and everything works!

Can anyone say why that is?


More information about the Digitalmars-d-learn mailing list