C++ Study Notes (4) - template template parameter

Template template parameter is a template parameter with template type. It is often used to seperate the logic and container. For example, the stack implementation:

```c++ template class CONT = std::deque > class stack { private: CONT elems; public: void push ( T const & ); void pop(); T top() const; bool empty() const { return elems.empty(); } };

template class CONT > void stack::push( T const& elem ) { elems.push_back( elem ); } … … ```

The dumb class in line #1 is the placeholder for the template parameter, the real parameter is determined in line #4. Here is the full version of stack.