foreach for ranges?
Jonathan M Davis
jmdavisProg at gmx.com
Tue Jul 17 21:54:31 PDT 2012
On Wednesday, July 18, 2012 06:27:28 Mike L. wrote:
> Thanks for the reply. Not sure how I missed it there. Interesting
> that the compiler has to be made aware of a concept that I had
> thought was only supposed to be part of phobos. Would it be
> possible to implement it in std.range using the new UFCs?
You can do
for(; !range.empty; range.popFront())
{
auto e = range.front;
}
without the compiler doing anything at all. But if you want
for(e; range)
{}
you need a way in the language for the compiler to translate that into the
above. UFCS has nothing to do with it. All UFCS does is take a.b(c, d) and
make it b(a, c, d).
- Jonathan M Davi
More information about the Digitalmars-d-learn
mailing list