use of typeof to determine auto type with ndslice examples

drug via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Sun Dec 20 20:39:23 PST 2015


21.12.2015 07:23, Jay Norwood пишет:
> import std.stdio;
> import std.experimental.ndslice;
>
> void main() {
>      import std.algorithm.iteration: map;
>      import std.array: array;
>      import std.range;
>      import std.traits;
>      auto t0 = 1000.iota.sliced(3, 4, 5);
>
>      pragma(msg, typeof(t0));
>      Slice!(3u, Result) t1 = 1000.iota.sliced(3, 4, 5);
>
> darn, I didn't duplicate the problem correctly.  It should be as above.
>
> and the error is:
>
> Slice!(3u, Result)
> src\app.d(12,2): Error: undefined identifier 'Result'
> dmd failed with exit code 1.
You can use
alias Type = typeof(t0);
Type t1 = 1000.iota.sliced(3, 4, 5);

IIRC Result is the Voldemort type. You can think of it as a detail of 
implementation of ndslice that isn't intended to be used by a ndslice 
user directly.


More information about the Digitalmars-d-learn mailing list