The following class template Sequencer contains a nested class template Process, with two template arguments.
template<typename P>
struct Sequencer
{
template<typename A , bool = A::CAN_BE_BUFFERED>
struct Process;
};
I would like to specialize Sequencer for a custom struct Foo while specializing its own version of Process to support just one template argument as follows
template<>
struct Sequencer<Bar>
{
template<typename A>
struct Process;
};
As the implementation is too long, I’ve posted the entire listing on ideone.
On GCC 4.5.3 I get the following error message
prog.cpp:60:24: error: partial specialization ‘Sequencer<Bar>::Process<A>’ does not specialize any template arguments
On Visual Studio 2008 I get the following error
prog.cpp(62) : error C2753: 'Sequencer<Bar>::Process<A>' : partial specialization cannot match argument list for primary template
Sequencer<Bar>::Processis a full template, it is not a specialization. It just happens to be a member of a specialization. You shouldn’t be declaring it as a specialization:Templates should be thought of as “class generators”.
Sequencer<P>defines a way to make classes from an arbitraryP, whereSequencer<Bar>gives a particular class to generate whenSequencer<Bar>is instantiated. Each generated class is totally separated and unrelated (beyond having been created by the same generator). In this case, this means that the inner class inSequencer<Bar>has no relationship with the inner class inSequencer<P>.