Partial specialization of template template parameters with a different number of parameters

If the name doesn't make sense, here is 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 essence, I want to specialize in different templates that take one type parameter. However, many templates in STL and other places have other parameters, such as Allocators and Compare (for example, std :: map). It doesn’t bother me. I want to specialize in std :: vector with a "hole", where T.

Thoughts? I feel like I need some kind of wrapper objects or some kind of indirect relation to achieve this - it will also probably change the way you instantiate these templates.

+4
source share
1 answer

In C ++ 11, you can use variables:

template <template<typename T, typename...> class ContainerOf> 
class Foo;
+2
source

All Articles