I'm using an C++ "event" class that allowed one or two arguments in the to be called delegates.
Lately I've added support for delegates that don't require arguments, however when I specialze the class to use no template arguments I'm still required to add <> afther the class definition.
Example usage with one/two arguments:
class Example
{
public:
event<int> SingleArgEvent;
event<int, int> DoubleArgEvent;
};
And here the no argument example:
class Example
{
public:
event<> NoArgTest1; // compiles just fine
event NoArgTest2; // gives me C2955: 'event' : use of class template requires template argument list
};
As it works with the brackets, I don't see a reason why they should to be there. Here's the class specialization code:
class null_typelist {};
/** event template **/
template <class Targ1 = null_typelist, class Targ2 = null_typelist>
class event : public event2_base<Targ1, Targ2>
{
};
template <class Targ>
class event<Targ, null_typelist> : public event1_base<Targ>
{
};
template <>
class event<null_typelist, null_typelist> : public event0_base
{
};