On Thursday, 22 September 2016 at 12:38:57 UTC, Nordlöw wrote:
Is ndslice' Slice() prepared for integration with containers
with reference counting semantics?
I wonder because according to the docs they internally store a
pointer and an offset. What is that pointer supposed to point
to except from obviously currently a GC-allocated array?
ndslice (i.e. Slice(size_t N, Range) ) is a generalization of D's
built-in slices (i.e. T) to N dimensions. Just like them, it
doesn't handle memory ownership - it just provides a view over
existing data. Usually, there are two use cases:
1) Wrapping an existing array:
1.1) You allocate an array however you want (GC, RC, plain
or just use a slice to an array returned from a
1.2) Wrap it via sliced 
1.3) Use it
1.4) Free it:
1.4.a) Let the GC reclaim it
1.4.b) Let the RC reclaim it
1.4.c) Free it manually.
2) Making a new array
2.1.a) Using the GC via slice 
2.1.b) Using std.experimental.allcator via makeSlice 
2.2) Use it
2.3) Free it:
2.3.a) Let the GC reclaim it automatically
2.3.b) Manually dispose  it from the allocator it was
(look for the allocator.dispose(tuple.array) pattern in
the examples of makeSlice).
Please note that the support for creating ndslices via custom
memory allocators (i.e. makeSlice) was added after dmd-2.071 was
branched, so you either have to wait for dmd-2.072, or use a
nightly build (which I recommend).