On Tuesday, 14 June 2016 at 14:47:11 UTC, Steven Schveighoffer
wrote:
On Tuesday, 14 June 2016 at 01:50:17 UTC, Era Scarecrow wrote:
return cast(inout(Slice)) Slice(cast(T*)ptr+a, b-a);
Better: inout(Slice)(ptr+a, b-a);
Of course... My amateur D-fu skills show themselves. cast()
const() immutable() are the same, why not inout? Hmmm...
Reminds me when I didn't understand how to get the address or
use pointers correctly, so I'd do stuff like &ptr[i] everywhere
because no one told me a better way to do it.
I also remember seeing odd issues and bugs in C when using a
char and then having negative numbers so having to use & 0xff
flags everywhere until I added the _unsigned_ keyword in.
I feel like a tutorial for common problems and solutions should
be present for C, C++ & D. Then again maybe that's some cookbooks
that I haven't purchased/read yet.