#include #include "stack.h" template std::ostream &operator<<(std::ostream &os, stack &s) { try { auto t = s.pop(); os << t << ' ' << s; s.push(t); } catch (const typename stack::empty &) { } return os; } template void push(stack &s, size_t n) { for (size_t i = 0; i < n; ++i) s.push(i); } template void pop(stack &s, size_t n) { try { for (size_t i = 0; i < n; ++i) s.pop(); } catch (const typename stack::empty &) { } } int main(int argc, char **argv) { const size_t N = 1000, S = 10; stack s; std::cout << "s = " << s << std::endl; push(s, S); std::cout << "s = " << s << std::endl; pop(s, S * S); std::cout << "s = " << s << std::endl; push(s, N); pop(s, N * N); push(s, N); }