Formal Review of std.range.ndslice

Stefan Frijters via Digitalmars-d digitalmars-d at puremagic.com
Sun Dec 13 07:25:11 PST 2015


On Friday, 11 December 2015 at 22:56:15 UTC, Ilya wrote:
> On Friday, 11 December 2015 at 19:31:14 UTC, Stefan Frijters 
> wrote:
>> [...]
>
>     Slice!(N, T*) arr;
>
>>     [...]
>
>       // compute length
>       // more flexible construtors would be added after
>       // allocatrs support for ndslice
>       size_t len = 1;
>       foreach(l; lengths)
>          len *= l;
>
>       arr = new T[len].sliced(lengths);
>
>> [...]
>
>    std.experimental.ndslice.selection: indexSlice, byElement;
>
>    foreach(p; someField.shape.indexSlice.byElement) {
>    	  someField[p] = foo(someOtherField[bar(p)]);
>           ...
>    }
>
>> [...]
>
> See also updated docs: 
> http://dtest.thecybershadow.net/artifact/website-13cbdcf17d84fc31328c3f517a56bea783c418d6-d9c63e815273f0906309088334e7dfb1/web/phobos-prerelease/std_experimental_ndslice.html
>
> Ilya

Thank you for your help. I'm trying to convert my code again at 
the moment, but ran into a new problem: I need to pass a pointer 
to the data into a C function. It seems that the .ptr property is 
not available, and using & caused dmd to segfault (currently 
running a Dustmite reduction for that). Is there any clean way to 
get a pointer to the underlying data?


More information about the Digitalmars-d mailing list