fork download
  1. #include<functional>
  2.  
  3. #define F(R, ...) std::function<R(__VA_ARGS__)>
  4. #define FuncType(N, R, ...) FUNC_##N(R, __VA_ARGS__)
  5. #define FUNC_0(R, ...) F(R)
  6. #define FUNC_1(R, _1, ...) F(R, _1)
  7. #define FUNC_2(R, _1, _2, ...) F(R, _1, _2)
  8. #define FUNC_3(R, _1, _2, _3, ...) F(R, _1, _2, _3)
  9.  
  10. int main() {
  11. static_assert(std::is_same<
  12. FuncType(2, void, int, char, double, int), // <--- see usage
  13. std::function<void(int, char)>
  14. >::value, "!");
  15. }
  16.  
Success #stdin #stdout 0s 3408KB
stdin
Standard input is empty
stdout
Standard output is empty