protocol for using InputRanges

Regan Heath regan at netmail.co.nz
Thu Mar 27 04:00:11 PDT 2014


On Thu, 27 Mar 2014 02:19:13 -0000, Steven Schveighoffer  
<schveiguy at yahoo.com> wrote:
> if(!r.empty)
> {
>     auto r2 = map!(x => x * 2)(r);
>     do
>     {
>        auto x = r2.front;
>        ...
>     } while(!r2.empty);
> }

if(r.empty)
   return;

auto r2 = map!(x => x * 2)(r);
while(!r2.empty)
{
    auto x = r2.front;
    ...
    r2.popFront();  //bug fix for your version which I noticed because I  
followed "the pattern" :D
}

ahh.. much better.

R

-- 
Using Opera's revolutionary email client: http://www.opera.com/mail/


More information about the Digitalmars-d mailing list