On Thursday, 22 October 2015 at 18:28:50 UTC, Ali Çehreli wrote:
If you already have a piece of memory, it is trivial to convert
it to a slice in D:
auto slice = existing_pointer[0 .. number_of_elements];
http://ddili.org/ders/d.en/pointers.html#ix_pointers.slice%20from%20pointer
The operation is not expensive because D slices are nothing but
a pointer and length.
Ali
Cool, I hadn't realized slices worked like that. Still, it was
more convenient to use fread and fwrite in this case. I had an
pointer where I wanted to be able to read and write one byte at a
time and fread/fwrite are familiar and comfortable options to me.