Using boost's preprocessor library (though having problems with clang++ and the variadic arguments o.O, works fine with g++):
#include <boost/preprocessor/facilities/expand.hpp>
#include <boost/preprocessor/seq/transform.hpp>
#include <boost/preprocessor/seq/enum.hpp>
#include <boost/preprocessor/variadic/to_seq.hpp>
#define CREATE_MFPTR(s, data, elem) \
& BOOST_PP_EXPAND(data) :: BOOST_PP_EXPAND(elem)
#define CREATE_MFPTRS(class_name, ...) \
BOOST_PP_SEQ_ENUM( \
BOOST_PP_SEQ_TRANSFORM(CREATE_MFPTR, \
class_name, \
BOOST_PP_VARIADIC_TO_SEQ(__VA_ARGS__)) \
) // end
struct test
{
void a();
void b();
void c();
void d();
};
using MFPtr = void (test::*)();
MFPtr arr[] = {
CREATE_MFPTRS(test, a,b,c,d)
};
int main() {}
the CREATE_MFPTRS(test, a,b,c,d)
yields
& test :: a, & test :: b, & test :: c, & test :: d