Tuple indexing and slicing

Timothee Cour thelastmammoth at gmail.com
Wed Jul 10 15:52:19 PDT 2013


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)
}
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.puremagic.com/pipermail/digitalmars-d-learn/attachments/20130710/5935e35d/attachment.html>


More information about the Digitalmars-d-learn mailing list