makiolo

lambdas capturing recursive variadic

Aug 30th, 2015
259
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /*
  2. Visual Studio 2015 Community
  3. problem with lambdas when capturing variadic vars from lambda
  4. */
  5. template <typename ... Args>
  6. void foo(Args&& ... args)
  7. {
  8.     auto fn = [&args...](){
  9.         auto fn2 = [&args...](){ // error C3493: 'args' cannot be implicitly captured because no default capture mode has been specified
  10.             std::cout << "hello world" << std::endl;
  11.         };
  12.         fn2();
  13.     };
  14.     fn();
  15. }
RAW Paste Data