pop & popFront combined
Ali Çehreli via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Sat Sep 20 14:02:23 PDT 2014
On 09/20/2014 11:59 AM, "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?
It is also related to exception safety. It took the C++ community to
realize that a Stack data structure with pop() returning the top object
cannot be made exception safe. The solution was to separate pop() from
top().
Here is the original paper demonstrating the impossibility:
http://ptgmedia.pearsoncmg.com/imprint_downloads/informit/aw/meyerscddemo/DEMO/MAGAZINE/CA_FRAME.HTM
Here is Herb Sutter's presentation of the solution:
http://www.gotw.ca/gotw/008.htm
Ali
More information about the Digitalmars-d-learn
mailing list