fork download
  1. #include <iostream>
  2. using namespace std;
  3. template<class... T>
  4. void Foo(T&&...){} //測試用
  5.  
  6. #define FOO_1(x, ...) std::make_pair(x, #x) //這邊預期是做出兩個std::pair<int, const char*>
  7. #define FOO_2(x, ...) FOO_1(x), FOO_1(__VA_ARGS__) //預期產生 FOO_1(a), FOO_1(b)
  8. #define FOO_(N, ...) FOO_##N (__VA_ARGS__) //預期接成FOO_2(a,b)
  9. #define FOO(...) FOO_(2 /*為了簡化寫死*/, __VA_ARGS__)
  10. int main() {
  11. int a = 1;
  12. int b = 2;
  13. Foo(FOO(a, b));
  14. return 0;
  15. }
Success #stdin #stdout 0s 3408KB
stdin
Standard input is empty
stdout
Standard output is empty