Listing 1
#include <cassert> #include <deque> #include <list> #include <stack> #include <vector> template <typename S> void test_stack(S &stack) { stack.push(101); stack.push(102); stack.push(103); assert(3 == stack.size()); assert(103 == stack.top()); stack.pop(); assert(102 == stack.top()); stack.pop(); assert(101 == stack.top()); stack.pop(); assert(0 == stack.size()); } int main() { std::stack<int, std::deque<int> > s_deque; std::stack<int, std::vector<int> > s_vector; std::stack<int, std::list<int> > s_list; test_stack(s_deque); test_stack(s_vector); test_stack(s_list); }