Reputation: 4275
If the title doesn't make sense, here's the gist of the problem:
template <template <class> class ContainerOf>
class Foo;
template <>
class Foo<boost::optional> // works!
{
// ...
};
// ERROR! std::vector takes two parameters
// T and Alloc.
template <>
class Foo<std::vector>
{
// ...
};
In essense I want to specialize for various templates, that take a single type parameter. However, many templates in STL and elsewhere have other parameters such as Allocators, and Compare operations (e.g. std::map). I don't care about those. I want to specialize for a std::vector with a "hole" where T is.
Thoughts? I feel like I need some kind of wrapper objects, or some sort of indirection to achieve this - it would also probably change the way the user instantiates these templates.
Upvotes: 4
Views: 168
Reputation: 16324
In C++11 you can use variadics:
template <template<typename T, typename...> class ContainerOf>
class Foo;
Upvotes: 2