Reputation: 31597
I have DefineEvent
class template that I use to ease the definition of new event classes. It's looks like this (pretty hairy, I know):
template<class EventClass, class... Parents>
class DefineEvent : public virtual Event, public Parents...
{
public:
DefineEvent()
{
static const EventTypeInfo& info = TypeInfoParentSetter<EventClass>
::SetOnce<Parents...>(TypeInfoHolder<EventClass>::Instance());
}
};
The TypeInfoParentSetter
class I used there looks like this:
template<class EventClass>
class TypeInfoParentSetter
{
public:
template<class... Parents>
static const EventTypeInfo& SetOnce(TypeInfoHolder<EventClass>& holder)
{
// ...
}
};
I get a compilation error pointing to the ::SetOnce<Parents...>
line in DefineEvent()
, telling me that the compiler "expected primary-expression before '...' token". How do I fix this?
You can view the code in context here, but take note that it's pretty ugly.
Upvotes: 1
Views: 209
Reputation: 5342
You need to include one template keyword to denote nested name is template :
DefineEvent()
{
static const EventTypeInfo& info = TypeInfoParentSetter<EventClass>
:: template SetOnce<Parents...>(TypeInfoHolder<EventClass>::Instance());
}
and you forgot to make member function TypeInfoParentSetter<EventClass>::Set
static :
template<class... Parents>
static TypeInfoParentSetter<EventClass> Set(TypeInfoHolder<EventClass>& holder)
{
std::cout << "ParentSetter()\n";
return TypeInfoParentSetter<EventClass>();
}
check it: http://ideone.com/sNHMX
Upvotes: 4
Reputation: 9430
May be you must use "template" keyword before SetOnce:
template<class EventClass, class... Parents>
class DefineEvent : public virtual EventClass, public Parents...
{
public:
DefineEvent()
{
static const EventTypeInfo& info =
TypeInfoParentSetter<EventClass>::template SetOnce<Parents ...>(TypeInfoHolder<EventClass>::Instance());
}
};
Upvotes: 0