fork download
  1. #include<iostream>
  2. using namespace std;
  3.  
  4. template<class ... VFTs> int variadic_fun(VFTs ... vfts) {
  5. return sizeof ...(vfts);
  6. }
  7.  
  8.  
  9. template<int ... Ns> struct IntPack {
  10. template<class ... MemTs> static int variadic_memfun(MemTs ... MemArgs) {
  11. return variadic_fun(([=]() {
  12. cout << "MemArgs = " << MemArgs << "\n";
  13. cout << "Ns = " << Ns;
  14. // Note the nested expansion of MemArgs here:
  15. cout << "variadic_fun(MemArgs...) = " << variadic_fun(MemArgs ...) << "\n";
  16. cout << "MemArgs[Ns] = " << MemArgs[Ns] << "\n";
  17. return 0;
  18. })()...);
  19. }
  20. };
  21.  
  22.  
  23. int main() {
  24. IntPack<0, 1, 2>::variadic_memfun("123", "ABC", "XYZ");
  25. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp: In lambda function:
prog.cpp:12:32: error: parameter packs not expanded with '...':
prog.cpp:12:32: note:         'MemArgs'
prog.cpp:13:28: error: parameter packs not expanded with '...':
prog.cpp:13:28: note:         'Ns'
prog.cpp:15:69: error: expansion pattern '((const IntPack<Ns>::variadic_memfun(MemTs ...)::<lambda()>*)this)->IntPack<Ns>::variadic_memfun(MemTs ...)::<lambda()>::MemArgs' contains no argument packs
prog.cpp: In static member function 'static int IntPack<Ns>::variadic_memfun(MemTs ...)':
prog.cpp:18:9: error: expansion pattern '#'lambda_expr' not supported by dump_expr#<expression error>()' contains no argument packs
stdout
Standard output is empty