Re: use of typeof to determine auto type with ndslice examples
So, the extra confusion of the typeof(iota) Result return goes away when slicing arrays. auto a1 = new int[100]; auto t3 = a1.sliced(3,4,5); pragma(msg,typeof(t3)); //This prints Slice!(3u, int*) Slice!(3u, int*) t4 = a1.sliced(3,4,5); // and this works ok
Re: use of typeof to determine auto type with ndslice examples
On Monday, 21 December 2015 at 04:39:23 UTC, drug wrote: 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. ok, well this worked, so it seems to be something lacking in the description of iota's type rather than an issue with ndslice. alias RESULT = typeof(1000.iota); Slice!(3u, RESULT) t1 = 1000.iota.sliced(3, 4, 5); auto t2 = 1000.iota(); pragma(msg, typeof(t2)); This just prints Result. Ok, so what is the reason for not being able to know the type of a specified iota?
Re: use of typeof to determine auto type with ndslice examples
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.
Re: use of typeof to determine auto type with ndslice examples
On Monday, 21 December 2015 at 04:20:16 UTC, Jay Norwood wrote: I pulled down the std.experimental.ndslice examples and am attempting to build some of the examples and understand the types being used. I know don't need all these imports, but it is hard to guess which ones are needed, and the examples often don't provide them, which I suspect is a common gripe here. Anyway, I was expecting to be able to use the typeof pragma to print a type that could use as a fully specified type, and that doesn't seem to be the case. I get a compile error instead. DMD32 D Compiler v2.069.2 on win32, "dip80-ndslice": "~>0.8.4" Is there some other way to get a valid fully specified type for these sliced auto variables? 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) = 1000.iota.sliced(3, 4, 5); Slice!(3u, Result) src\app.d(12,2): Error: undefined identifier 'Result' dmd failed with exit code 1. No way that I know of. I've had this before with iota and its various forms. I have done this in the past: (or something similar, I haven't got my code handy ATM) --- alias RESULT = typeof(iota(1, 2, 3)); ... Slice!(3u, RESULT) = 1000.iota.sliced(3, 4, 5); --- Note that iota(1) and iota(1, 2, 3) return different types so you would require two different RESULT aliases. bye, lobo
Re: use of typeof to determine auto type with ndslice examples
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.