mercredi 21 novembre 2018

How can I specialise a template with a template?

Consider a template class

template<class T>
class Foo
{
};

for which I can write a simple specialisation

template<>
class Foo<int>
{
};

I have a situation where I want to specialise Foo with a template class, in detail with a bool which serves as a compile-time flag:

template<>
class Foo<int, bool> // Clearly not the correct notation.
{

}

Uses would include Foo<1, true> and Foo<1, false>.

What is the correct notation for the class name, where I've marked "Clearly not the correct notation."?

I code to the C++11 standard.

Aucun commentaire:

Enregistrer un commentaire