fork download
  1. #include <memory>
  2. #include <iostream>
  3. #include <algorithm>
  4.  
  5. struct A {
  6.  
  7. void member()
  8. {
  9. auto p = std::make_unique<int>(42);
  10.  
  11. const std::vector<int> f {1, 3, 4};
  12.  
  13.  
  14. auto l = [ p { std::move(p) } ](int val) { return val == 5 ? true : false ;};
  15.  
  16. //auto l2 = l; // если расскоментировать эту строчку, компилироваться перестанет
  17.  
  18.  
  19. /*
  20.   if(std::find_if(f.cbegin(), f.cend(),
  21.   [ p { std::move(p) } ](int val) { return val == 5 ? true : false ;}) == f.cend() )
  22.   std::cout << "Not found" << std::endl;
  23.   */
  24.  
  25. }
  26. };
  27. int main()
  28. {
  29.  
  30. A a;
  31. a.member();
  32.  
  33. }
Success #stdin #stdout 0s 3452KB
stdin
Standard input is empty
stdout
Standard output is empty