Implicit conversions of head-const to tail-const ranges
Paul Backus
snarwin at gmail.com
Wed Mar 24 13:09:15 UTC 2021
On Wednesday, 24 March 2021 at 10:25:41 UTC, Per Nordlöw wrote:
> On Tuesday, 23 March 2021 at 20:44:03 UTC, Paul Backus wrote:
>> 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)`.
>
> I don't quite follow what this refers to. Can you give a code
> reference or sample?
struct Example(T)
{
static if (isMutable!T)
T t;
else
T* ptr;
}
It would be incorrect to allow `const(Example!int)` to implicitly
convert to `Example!(const(int))`.
More information about the Digitalmars-d
mailing list