On Monday, 13 June 2016 at 23:51:40 UTC, Era Scarecrow wrote:
inout(Slice) opSlice(size_t a, size_t b) inout
{
return cast(inout(Slice)) Slice(ptr+a, b-a);
}
Seems the pointer has to be force-cast back to a normal pointer
so the constructor can work. (Because the function is inout, ptr
becomes inout(T*) )
return cast(inout(Slice)) Slice(cast(T*)ptr+a, b-a);
Beyond that it works as expected :) Writeln gives the following
output on Slice with opSlices:
Slice!int(18FD60, 10)
const(Slice!int)(18FD60, 10)
immutable(Slice!int)(18FD90, 10)