struct Slice(T) { T* ptr; size_t length; Slice!(inout(T)) opSlice(size_t a, size_t b) inout { return Slice!(inout(T))(ptr+a, b-a); } }
I'm writing a custom (originally multi-dimensional) Slice-type,
analogous to the builtin T[], and stumbled upon the problem that
the following code won't compile. The workaround is simple: just
write the function three times for mutable/const/immutable. But
as "inout" was invented to make that unneccessary I was wondering
if there is a clever way to make this work.
- nested inout return type Simon Bürger via Digitalmars-d-learn
- Re: nested inout return ... Era Scarecrow via Digitalmars-d-learn
- Re: nested inout ret... Era Scarecrow via Digitalmars-d-learn
- Re: nested inout... Simon Bürger via Digitalmars-d-learn
- Re: nested i... Steven Schveighoffer via Digitalmars-d-learn
- Re: nes... Simon Bürger via Digitalmars-d-learn
- Re: nes... Era Scarecrow via Digitalmars-d-learn