mercredi 20 juillet 2016

How to write a template that could be specialised with an object or an int N

For a class Foo, I currently have

template <typename T, template <typename> typename Y > class Foo{};

The reason for that is that, I want to specialise it for

template<typename T> class Foo, int N>{};

and, given a struct Bar{},

template<typename T> class Foo<T, Bar>{};

But the compiler (C++11, ideone.com), outputs the error "error: template argument 2 is invalid" on the lines with the specification.

Presumably I've formed the unspecialised declaration incorrectly. Or is this even possible?

Aucun commentaire:

Enregistrer un commentaire