mir: How to change iterator?

jmh530 john.michael.hall at gmail.com
Sun Apr 19 22:07:30 UTC 2020


On Thursday, 16 April 2020 at 20:59:36 UTC, jmh530 wrote:
> [snip]
>
> /+dub.sdl:
> dependency "mir-algorithm" version="~>3.7.28"
> +/
>
> import mir.ndslice;
>
> void foo(Iterator, SliceKind kind)(Slice!(Iterator, 1, kind) x, 
> Slice!(Iterator, 1, kind) y) {
>     import std.stdio : writeln;
>     writeln("here");
> }
>
> void main() {
>     auto x = [0.5, 0.5].sliced(2);
>     auto y = x * 5.0;
>     foo(x, y);
> }

This is really what I was looking for (need to make allocation, 
unfortunately)

/+dub.sdl:
dependency "mir-algorithm" version="~>3.7.28"
+/

import mir.ndslice;

void foo(Iterator, SliceKind kind)(Slice!(Iterator, 1, kind) x, 
Slice!(Iterator, 1, kind) y) {
     import std.stdio : writeln;
     writeln("here");
}

void main() {
     auto x = [0.5, 0.5].sliced(2);
     auto y = x * 5.0;
     foo(x, y.slice);
}


More information about the Digitalmars-d-learn mailing list