On Thu, Jul 11, 2013 at 1:05 AM, Simen Kjaeraas <simen.kja...@gmail.com>wrote:
> On 2013-07-11, 00:52, Timothee Cour wrote: > > Why not support Tuple indexing and slicing with [] syntax? >> (see below for a way to index/slice a tuple) >> >> void main(){ >> alias T=Tuple!(int,double); >> pragma(msg,T[0].stringof);//_**expand_field_0 >> //pragma(msg,T[0..2].stringof)**; //Error: cannot slice type >> 'Tuple!(int, >> double) >> pragma(msg,typeof(T.init[0]).**stringof);//int >> pragma(msg,typeof(tuple(T.**init[0..$])).stringof);//** >> Tuple!(int,double) >> } >> > > This works: > > import std.typecons : Tuple, tuple; > void main() { > alias T = Tuple!(int, string, float); > T a; > Tuple!(int, string) b = tuple(a[0..2]); // Slicing values. > Tuple!(T.Types[1..3]) c; // Slicing types. > } > > -- > Simen > ah, yes, I forgot about Types, thanks! Documentation for it could be improved though...