pop & popFront combined

Jakob Ovrum via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Sat Sep 20 12:23:45 PDT 2014


On Saturday, 20 September 2014 at 18:59:03 UTC, Nordlöw wrote:
> Is there a reason why popFront doesn't automatically return 
> what front does?
>
> If so I'm still missing a combined variant of pop and popFront 
> in std.range.
> Why isn't such a common operation in Phobos already?

Sometimes after popping, the previous `front` is no longer valid, 
such as in the case of a buffer being reused. We should be 
careful about promoting using a previously read `front` after 
`popFront` until we figure out what we want to do about these 
"transient ranges".

If you want move semantics, use `moveFront`.


More information about the Digitalmars-d-learn mailing list