Skip to content

Instantly share code, notes, and snippets.

@yannick
Created May 4, 2015 13:12
Show Gist options
  • Select an option

  • Save yannick/1636d9f3c1da2172875e to your computer and use it in GitHub Desktop.

Select an option

Save yannick/1636d9f3c1da2172875e to your computer and use it in GitHub Desktop.
import std.stdio;
import std.container.dlist;
void main()
{
auto dl = DList!string();
dl.insertBack("eins");
dl.insertBack("zwei");
dl.insertBack("polizei");
foreach(s; dl[])
{
writeln(s);
}
auto dl2 = new DList!string();
dl2.insertBack("eins");
dl2.insertBack("zwei");
dl2.insertBack("polizei");
foreach(s; dl2[]) // Fails with: Error: need upper and lower bound to slice pointer
{
writeln(s);
}
}
@yannick

yannick commented May 4, 2015

Copy link
Copy Markdown
Author
15:12:47  Destructionator | oh if it is a stuct pointer you gotta access the operator a different way. either (*list)[] or list.opSlice()                                                                                                                                dgoon-cloud     
15:13:19  Destructionator | [] on a pointer has a meaning on its own so it won't call the overloaded thing automatically                

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment