Regarding the legacy code that I was asked to work with, I came across a concept that I don’t understand. Searching in SO and googling did not help, therefore, this question.
There is a template class that looks like this:
template<int Index_t, int Kind_t, ProtocolType Prot_t, class Protocol> class CommandHandlerGeneric : private CommandHandlerGeneric<Index_t-1, Kind_t, Prot_t, Protocol> { public: CommandHandlerGeneric(Protocol& Shared, CmdHandlerBase** Cont) : CommandHandlerGeneric<Index_t-1, Kind_t, Prot_t, Protocol>(Shared, Cont) {} };
The CmdHandlerBase class is not a template class that exists elsewhere in a different header. Following the definition above, there is a macro that looks like this:
#define REGISTER_COMMAND_HANDLER_BASE(CmdIndex, CmdType, CmdKind, ProtType) \ template<class Protocol> \ class CommandHandlerGeneric<CmdIndex, CmdKind, ProtType, Protocol> : private CommandHandlerGeneric<CmdIndex-1, CmdKind, ProtType, Protocol> \ { \ CmdType m_Cmd;\ public: \ CommandHandlerGeneric(Protocol& Shared, CmdHandlerBase** Cont) : \ m_Cmd(Shared), \ CommandHandlerGeneric<CmdIndex-1, CmdKind, ProtType, Protocol>(Shared, Cont) \ { Cont[CmdIndex] = &m_Cmd; } \ };
It appears that the specified macro partially specializes in the CommandHandlerGeneric class CommandHandlerGeneric . It's right? What is the rationale for withdrawing a private lesson from oneself?