Comment #0 by john.michael.hall — 2022-11-30T14:57:31Z
From here (among other places) on the forum
https://forum.dlang.org/post/[email protected]
Allow `const type!T` to convert to `type!(const T)`
Similarly, allow `immutable type!T` to convert to `type!(immutable T)`
Comment #1 by john.michael.hall — 2022-11-30T18:21:11Z
In the past the argument from Walter against something like opImplicitCast has always been that users would get confused about random things happening if they had freedom to do any implicit cast they could think of.
The solution to this would be only to allow the implicit conversions discussed above. So instead of some general opImplicitCast it might be better described as opImplicitConstCast.
Comment #2 by nick — 2022-12-04T18:19:34Z
> Similarly, allow `immutable type!T` to convert to `type!(immutable T)`
That isn't always safe:
struct S(T)
{
int* p;
}
void main()
{
auto s = S!(immutable int)();
immutable si = S!int();
s = si; // currently an error
*s.p = 4;
assert(*si.p == 0); // fails
}
Comment #3 by robert.schadek — 2024-12-13T19:26:02Z