Why std::stack and std::queue use type template parameter instead template template parameter for underlying container type?
I.e. why is stack declared like this:
template<typename T, typename Container = deque<T>>
template<typename T, template<typename> class Container = deque>
Because typically containers like
std::vector have more than one template argument. By not caring about it being a template, you allow every kind of container to be used.
template<class T, class Allocator = std::allocator<T>> class vector;
template<typename> class Container
as you would have it in your
stack? Hint it doesn't! You'd need special cases for each number of template arguments you'd want to support, which is silly, because these typically don't contribute any more information than a simple
Note that to get at the actual template arguments of e.g. a
std::vector, you have the typedefs
std::vector::allocator_type, removing the need of having these types available explicitly where you actually use the type (i.e. the