If I do not to want to create a new container in order to do so?
Posting b/c I found this useful for debugging. Pop from original into a temp and then pop from temp back into original:
template
void dump_stack(std::stack& stack) {
std::stack temp;
while (!stack.empty()) {
T top = stack.top(); stack.pop();
std::cout << top << " ";
temp.push(top);
}
while (!temp.empty()) {
T top = temp.top(); temp.pop();
stack.push(top);
}
}