C ++ template types nested in a template class definition

I have a situation where there is a class definition that looks like this:

template<class T>
class Alpha< Bravo<T> >
{
....
};

I am compiling with gnu g ++, and the compiler complains that Alpha is "not a template."

I saw the same method that was used in the library in which Bravo was written, and Bravo is a template class. Am I missing something? I stripped Alpha to the marrow of my bones and tested without compilation success. I also tried to copy + paste the code from the place where I saw it while working in the Bravo library, and the same thing, without success and the same error.

Thanks in advance.

+3
source share
2 answers

; , .

template<class T>
class Alpha;

template<class T>
class Alpha<Bravo<T> >
{
    // ...
};
+6

. , , .

//primary template - the definition is optional
template<class T>
class Alpha
{
};

//specialization
template<class T>
class Alpha< Bravo<T> >
{
};
+4

All Articles