Advertisement
Guest User

Untitled

a guest
Apr 7th, 2014
147
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
D 0.42 KB | None | 0 0
  1. template Tuple (E...)
  2. {
  3.     alias Tuple = E;
  4. }
  5.  
  6. void main ()
  7. {
  8.     // Would be a string tuple.
  9.     alias SomeTuple = Tuple!();
  10.     int[string] map = [];
  11.  
  12.     // Does not work. `i` is not known at compile time. Intentional.
  13.     // `foreach (int i, string e; SomeTuple)` would make it work.
  14.     for (int i = 0; i < SomeTuple.length; ++i)
  15.     {
  16.         // This crashes DMD.
  17.         auto a = map[SomeTuple[i]];
  18.     }
  19. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement