Implicit conversion to mutable if no indirections?
Simen Kjærås
simen.kjaras at gmail.com
Wed Sep 7 13:40:42 UTC 2022
On Tuesday, 6 September 2022 at 17:45:50 UTC, Nick Treleaven
wrote:
> On Tuesday, 6 September 2022 at 10:06:59 UTC, Quirin Schroll
> wrote:
>> * Aforementioned `const(int*)` becoming `const(int)*`. That
>> does not happen with custom `struct S(T)` automatically even
>> in cases where it is provably correct, and there is no way to
>> tell the D compiler that copies of `const(S!int)` are better
>> understood to be `S!(const int)`.
>
> There is at least a library pattern:
> https://dlang.org/blog/2020/06/25/a-pattern-for-head-mutable-structures/
I really wish that had gone somewhere. There's not a lot of code
to it, it's almost all library code that the user doesn't see,
and it would provide a solution while we wait for the promised
compiler support for the same thing (which I don't think would be
very different - you'll need to specify the behavior for complex
cases anyway). Also, it's not worth a whole lot as a library if
Phobos doesn't implement it.
--
Simen
More information about the Digitalmars-d
mailing list