"bearophile" <[email protected]> wrote in message news:[email protected]... > Nick Sabalausky: > >> Not that slicing a stack would be all that common, but if it were done >> for >> whatever reason... > > Is it possible to write a function like: > > ForeachType!A unsafePop(A)(A)if(isDynamicArray!A) { /*...*/ } > > that contains both the popping (and something like assumeSafeAppend to > mess with the druntime data structures) and use it to allow a stack-like > usage of D dynamic arrays? (This function is not meant to replace the > usage of a proper stack data structure based on a deque when you need a > heavy-duty stack, but it's handy in other lighter cases). >
Umm, maybe. Sounds like it should be feasable, though I haven't tried. Although going by what Steve said about assumeSafeAppend, it might actually end up slower than a wrapped Stack type that doesn't use assumeSafeAppend.
