Proposal: takeFront and takeBack
Christophe Travert
travert at phare.normalesup.org
Tue Jul 3 11:12:54 PDT 2012
Range have been designed with the idea that front is valid until next
call to popFront. If popFront was to be called right after front, then
it would just be a popFront that returns a value, and maybe a justPop or
something if you don't want to copy the value.
It's delicate to come now and decide that if a previously returned front
value is no longer valid after a call to popFront, it should be
documented by an enum. Who is going to review all libraries (written and
to come) to make sure the enum is placed when it should be? The reverse
should be done instead: if you want you range to be optimized by calling
takeFront, define something (for example... takeFront). Then use
algorithms that are specialized for takeFront.
More information about the Digitalmars-d
mailing list