Really in need of help with std.container.array.d

Robert burner Schadek via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Tue Oct 14 09:08:30 PDT 2014


On Tuesday, 14 October 2014 at 12:51:29 UTC, Nordlöw wrote:

>
> Could you please give me a code example? I'm not skilled enough 
> in D to follow this description.

struct Range(T) {
   Array!S array;
   T opIndex(size_t i) {
      return cast(T)array[i];
   }
}

struct Array(T) {
   Range!(const(T)) opSlice() const {
      return Range!(const(T))(cast(Array!T)array, 0, length);
   }

   Range!(T) opSlice() const {
     return Range!(T)(cast(Array!T)array, 0, length);
   }
}





More information about the Digitalmars-d-learn mailing list