I want to do this:
template <enum Type>
class Message {
private:
Type m_type
};
enum StdInMessages { PrintHello, Echo, ... };
class StdInMsg : Message<StdInMessages>
{ ... }
enum NetworkMessages { DoSomethingElse, Shutdown ... };
class NetworkMsg : Message<NetworkMessages>
{ ... }
Of course, the actual messages are slightly different
Why doesn’t this work?
template <enum T> class ATemplate {};
I get this error
error: use of enum ‘T’ without previous declaration
Because that’s not valid syntax for a template unless what you’re looking for is what Konrad answered.
You need to either use
typenameorclass.The following should do it: