Re: tuple slicing operator

2014-08-10 Thread via Digitalmars-d-learn
On Saturday, 9 August 2014 at 19:26:46 UTC, Meta wrote: On Saturday, 9 August 2014 at 16:39:34 UTC, Vlad Levenfeld wrote: I may be misunderstanding the intended semantics of the [] operator but I've come to interpret x[] to mean give me x as a range and this is the meaning I intend when I

tuple slicing operator

2014-08-09 Thread Vlad Levenfeld via Digitalmars-d-learn
I may be misunderstanding the intended semantics of the [] operator but I've come to interpret x[] to mean give me x as a range and this is the meaning I intend when I overload it in my own structs. But - auto z = tuple (1,1,1); pragma (msg, typeof(z)); // Tuple!(int, int, int) pragma (msg,

Re: tuple slicing operator

2014-08-09 Thread Meta via Digitalmars-d-learn
On Saturday, 9 August 2014 at 16:39:34 UTC, Vlad Levenfeld wrote: I may be misunderstanding the intended semantics of the [] operator but I've come to interpret x[] to mean give me x as a range and this is the meaning I intend when I overload it in my own structs. But - auto z = tuple

Re: tuple slicing operator

2014-08-09 Thread Vlad Levenfeld via Digitalmars-d-learn
On Saturday, 9 August 2014 at 19:26:46 UTC, Meta wrote: (which is why z[] gives you a type of (int, int, int) instead of Tuple!(int, int, int)). That makes sense, and on second thought it wouldn't make sense to use a tuple as a range because it's not guaranteed to have only one element type.

Re: tuple slicing operator

2014-08-09 Thread Meta via Digitalmars-d-learn
On Saturday, 9 August 2014 at 20:32:05 UTC, Vlad Levenfeld wrote: Are there any specific cases where they're not? Not that I know of, and it doesn't really make sense for them not to be, but it could happen. If you want to be certain that slicing a type will produce a valid range, you can do