On Wed, Jul 10, 2013 at 5:49 PM, Artur Skawina <span dir="ltr"><<a href="mailto:art.08.09@gmail.com" target="_blank">art.08.09@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="im">On 07/11/13 00:52, Timothee Cour wrote:<br>
> Why not support Tuple indexing and slicing with [] syntax?<br>
>  (see below for a way to index/slice a tuple)<br>
<br>
</div>Not sure I understand the question.<br>
I guess you'd like this to work for some library pseudo-tuple type<br>
- I've not looked at those, somebody else may give you a better answer.<br>
<br>
"Native" tuples already support what you're asking for:<br>
<br>
   template Tuple(A...) { alias Tuple = A; }<br>
<div class="im"><br>
   void main(){<br>
     alias T=Tuple!(int,double);<br>
     pragma(msg,T[0].stringof);<br>
</div>     pragma(msg,T[0..2].stringof);<br>
     pragma(msg,typeof(T.init[0]).stringof);<br>
     pragma(msg,typeof(Tuple!(T.init[0..$])).stringof);<br>
   }<br>
<span class="HOEnZb"><font color="#888888"><br>
artur<br>
</font></span></blockquote></div><br><div>I know native tuples do, I am aksing about std.typecons.Tuple.</div><div>Is there any way to support this in library code ?</div><div>If not, how about changing compiler to allow this?</div>
<div><br></div><div>I'd like that:</div><div><div>static assert(is(Tuple!(int,double)[0]==int));</div></div><div><div>static assert(is(Tuple!(int,double)[0..$]==Tuple!(int,double)));</div></div><div><br></div><div><br>
</div>