fork(1) download
  1. #include <iostream>
  2. #include <mutex>
  3. using namespace std;
  4.  
  5. std::once_flag flag;
  6.  
  7. template<typename ...Args>
  8. void gFunc(Args... args)
  9. {
  10. }
  11.  
  12. template<typename ...Args>
  13. void func(Args... args)
  14. {
  15. auto lm = [&, args...]
  16. {
  17. // more code here
  18. return gFunc(args...);
  19. };
  20. std::call_once(flag,lm);
  21. }
  22.  
  23. int main() {
  24. // your code goes here
  25. func(1);
  26. return 0;
  27. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp: In function ‘void func(Args ...)’:
prog.cpp:15:20: error: expected ‘,’ before ‘...’ token
  auto lm = [&, args...] 
                    ^
prog.cpp:15:20: error: expected identifier before ‘...’ token
prog.cpp:15:23: error: parameter packs not expanded with ‘...’:
  auto lm = [&, args...] 
                       ^
prog.cpp:15:23: note:         ‘args’
prog.cpp: In lambda function:
prog.cpp:18:31: error: expansion pattern ‘args’ contains no argument packs
              return gFunc(args...);
                               ^
prog.cpp: In instantiation of ‘struct func(Args ...) [with Args = {int}]::__lambda0’:
prog.cpp:19:12:   required from ‘void func(Args ...) [with Args = {int}]’
prog.cpp:25:8:   required from here
prog.cpp:15:16: error: using invalid field ‘func(Args ...)::__lambda0::__args’
  auto lm = [&, args...] 
                ^
stdout
Standard output is empty