Home > OS >  variadic number of methods as template input parameter
variadic number of methods as template input parameter

Time:11-11

Is it possible to specify a member-function template parameter pack? Something like this:

template <typename foo, void (foo::*bar)(void) ...>
void application()
{
}

None of my solutions work, and I would like to avoid putting every function that I'm gonna use in a struct.

CodePudding user response:

The syntax for this is

template <typename C, void (C::*...mfuncs)()>
void application()
{
    // ...
}

or with typedef:

template <typename C>
using MemberFunc = void (C::*)();

template <typename C, MemberFunc<C>...mfuncs>
void application();
  • Related