This is what you need:
#include <vector>
template <typename T, template<typename, typename> class C>
class TSContainer
{
C<T, std::allocator<T> > container;
};
int main() {
TSContainer<int, std::vector> a;
}
Note that std::vector
takes two template parameters with the second being defaulted to std::allocator
. Alternatively, you can write:
#include <vector>
template <typename T, template<typename, typename = std::allocator<T> > class C>
class TSContainer
{
C<T> container;
};
int main() {
TSContainer<int, std::vector> a;
}
Both of these force the selection of the allocator on you. If you want to control which allocator is used by your vector (i.e. what is used as second template parameter to C
), you can also use this:
#include <vector>
template <typename T, template<typename, typename> class C, typename A = std::allocator<T> >
class TSContainer
{
C<T, A> container;
};
int main() {
TSContainer<int, std::vector> a;
}
This is the most flexible solution.