On Thu, Jul 11, 2013 at 1:05 AM, Simen Kjaeraas <span dir="ltr"><<a href="mailto:simen.kjaras@gmail.com" target="_blank">simen.kjaras@gmail.com</a>></span> wrote:<br><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div class="HOEnZb"><div class="h5">On 2013-07-11, 00:52, Timothee Cour wrote:<br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Why not support Tuple indexing and slicing with [] syntax?<br>
 (see below for a way to index/slice a tuple)<br>
<br>
void main(){<br>
  alias T=Tuple!(int,double);<br>
  pragma(msg,T[0].stringof);//_<u></u>expand_field_0<br>
  //pragma(msg,T[0..2].stringof)<u></u>; //Error: cannot slice type 'Tuple!(int,<br>
double)<br>
  pragma(msg,typeof(T.init[0]).<u></u>stringof);//int<br>
  pragma(msg,typeof(tuple(T.<u></u>init[0..$])).stringof);//<u></u>Tuple!(int,double)<br>
}<br>
</blockquote>
<br></div></div>
This works:<br>
<br>
import std.typecons : Tuple, tuple;<br>
void main() {<br>
    alias T = Tuple!(int, string, float);<br>
    T a;<br>
    Tuple!(int, string) b = tuple(a[0..2]); // Slicing values.<br>
    Tuple!(T.Types[1..3]) c; // Slicing types.<br>
}<span class="HOEnZb"><font color="#888888"><br>
<br>
-- <br>
Simen<br>
</font></span></blockquote></div><br><div><br></div><div>ah, yes, I forgot about Types, thanks! Documentation for it could be improved though...</div>