popFrontExactly?

monarch_dodra monarchdodra at gmail.com
Sun Nov 18 12:34:37 PST 2012


How does the community feel about having a "popFrontExactly" in 
phobos?

"popFrontN" is like "take": Safe, but more costly: It double 
checks there actually *are* "n" elements in the range, and if 
not, stops pop-ing.

When using popFrontN, more often than not, the "n" value is 
extracted from iterating the range already, so we *know* there 
are "n" elements in the range. In that case, popFrontN is 
un-necesarilly costly.

In that case, we could have "popFrontExactly", which would 
operate like "takeExactly": It would pre-assume that the *are* n 
elements, and assert otherwise.

--------
I know I've had the usecase for this in the past. Performance and 
convenience gains are there for both forward and sliceable ranges.

Should I push a pull request adding such a function (and its 
friends) to phobos? How does the group feel about such functions?



More information about the Digitalmars-d mailing list