nested inout return type

Era Scarecrow via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Mon Jun 13 16:51:40 PDT 2016


On Monday, 13 June 2016 at 22:31:00 UTC, Simon Bürger wrote:
> But as "inout" was invented to make that unneccessary I was 
> wondering if there is a clever way to make this work.
>
>     <snip>
>
>     Slice!(inout(T)) opSlice(size_t a, size_t b) inout
>     {
>         return Slice!(inout(T))(ptr+a, b-a);
>     }

  Hmmm. Wouldn't just returning an inout of the Slice work? 
Otherwise you'll get inner template instantiation and that can be 
annoying

      inout(Slice) opSlice(size_t a, size_t b) inout
      {
          return cast(inout(Slice)) Slice(ptr+a, b-a);
      }


More information about the Digitalmars-d-learn mailing list