Question

Let's say I have a template functor :

template <class U, class V>
struct Converter
{
    V& operator() (const U&, V&) const;
};

I want to "specialize" this converter over a template class and a non-template class :

template<>
struct Converter <template<class> MyTemplateClass, MyNonTemplateClass>
{
    //I can't use MyTemplateClass without specializing it 
    //even if I don't need it to perform the computation
};

Of course, this can't work. How would you do to achieve a similar result ?

Était-ce utile?

La solution

You need to move the type for template<class> MyTemplateClass up in template declaration for Converter.

template<class T>
struct Converter <MyTemplateClass<T>, MyNonTemplateClass>
{
    //...
};
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top