pop & popFront combined
    "Nordlöw" via Digitalmars-d-learn 
    digitalmars-d-learn at puremagic.com
       
    Sat Nov  1 04:43:26 PDT 2014
    
    
  
On Saturday, 20 September 2014 at 19:23:46 UTC, Jakob Ovrum wrote:
> If you want move semantics, use `moveFront`.
But x.moveFront doesn't modify x.
What I want is to transform my uses of std.range from
if (!x.empty)
{
     x.front.doStuff;
     x.popFront;
}
into
if (!x.empty)
     if (auto front = x.stealFront)
     {
         front.doStuff;
     }
This is more functional/atomic, that is it reduces the risk of 
accidentally forgetting to call popFront at the end.
Destroy!
    
    
More information about the Digitalmars-d-learn
mailing list