On Thursday, 8 May 2014 at 07:09:24 UTC, Sönke Ludwig wrote:
Just a general note: This is not only interesting for range/slice types, but for any user defined reference type (e.g. RefCounted!T or Isolated!T).

Not necessarily: As soon as indirections come into play, you are basically screwed, since const is "turtles all the way down".

So for example, the conversion from "const RefCounted!T" to "RefCounted!(const T)" is simply not possible, because it strips the const-ness of the ref count.

What we would *really* need here is NOT:
"const RefCounted!T" => "RefCounted!(const T)"
But rather
"RefCounted!T" => "RefCounted!(const T)"

The idea is to cut out the "head const" directly. This also applies to most ranges too BTW.

We'd be much better of if we never used `const MyRange!T` to begin with, but simply had a conversion from `MyRange!T` to `MyRange!(const T)`, which references the same data.

In fact, I'm wondering if this might not be a more interesting direction to explore.

Reply via email to