你可以用
__VA_ARGS__
作为lambda参数,然后将该lambda转换为函数指针并提取参数类型:
template <typename T> struct func_param {};
template <typename T> struct func_param<void(*)(T)> {using type = T;};
#define FOO(...) \
do \
{ \
auto lambda = +[]([[maybe_unused]] __VA_ARGS__) {}; \
using type = func_param<decltype(lambda)>::type; \
/* Do something with `type`. */\
} \
while (0);