Implicit conversions of head-const to tail-const ranges

Paul Backus snarwin at gmail.com
Tue Mar 23 20:44:03 UTC 2021


On Tuesday, 23 March 2021 at 16:50:24 UTC, Per Nordlöw wrote:
> Has there been any attempts in dmd to generalize implicit 
> conversions to allow implicit conversion of a head-const to 
> tail-const range? Similar to what already happens for dynamic 
> arrays (slices).
>
> Are there any apparent show-stoppers?

As far as I know the main reason this hasn't been done is that it 
requires user-defined implicit conversions (something like 
"opHeadMutable"), which Walter is generally opposed to.

You can't do a naive `const(Range!T)` -> `Range!(const(T))` 
conversion, because there may be `static if` statements (or other 
reflection) inside the `Range` template that cause incompatible 
structs to be generated for `T` and `const(T)`.


More information about the Digitalmars-d mailing list