fork(2) 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. const std::vector<int> f {1, 3, 4};
  11. if(std::find_if(f.cbegin(), f.cend(),
  12. [ p { std::move(p) } ](int val) { return val == 5 ? true : false ;}) == f.cend() )
  13. std::cout << "Not found" << std::endl;
  14.  
  15. }
  16. };
  17. int main()
  18. {
  19.  
  20. A a;
  21. a.member();
  22.  
  23. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
In file included from /usr/include/c++/5/algorithm:62:0,
                 from prog.cpp:3:
/usr/include/c++/5/bits/stl_algo.h: In instantiation of '_IIter std::find_if(_IIter, _IIter, _Predicate) [with _IIter = __gnu_cxx::__normal_iterator<const int*, std::vector<int> >; _Predicate = A::member()::<lambda(int)>]':
prog.cpp:12:82:   required from here
/usr/include/c++/5/bits/stl_algo.h:3816:37: error: use of deleted function 'A::member()::<lambda(int)>::<lambda>(const A::member()::<lambda(int)>&)'
        __gnu_cxx::__ops::__pred_iter(__pred));
                                     ^
prog.cpp:12:35: note: 'A::member()::<lambda(int)>::<lambda>(const A::member()::<lambda(int)>&)' is implicitly deleted because the default definition would be ill-formed:
              [ p { std::move(p) } ](int val) {  return val == 5 ? true : false ;}) == f.cend() )
                                   ^
prog.cpp:12:35: error: use of deleted function 'std::unique_ptr<_Tp, _Dp>::unique_ptr(const std::unique_ptr<_Tp, _Dp>&) [with _Tp = int; _Dp = std::default_delete<int>]'
In file included from /usr/include/c++/5/memory:81:0,
                 from prog.cpp:1:
/usr/include/c++/5/bits/unique_ptr.h:356:7: note: declared here
       unique_ptr(const unique_ptr&) = delete;
       ^
In file included from /usr/include/c++/5/bits/stl_algobase.h:71:0,
                 from /usr/include/c++/5/memory:62,
                 from prog.cpp:1:
/usr/include/c++/5/bits/predefined_ops.h:239:5: note:   initializing argument 1 of '__gnu_cxx::__ops::_Iter_pred<_Predicate> __gnu_cxx::__ops::__pred_iter(_Predicate) [with _Predicate = A::member()::<lambda(int)>]'
     __pred_iter(_Predicate __pred)
     ^
/usr/include/c++/5/bits/predefined_ops.h:239:5: error: '__gnu_cxx::__ops::_Iter_pred<_Predicate> __gnu_cxx::__ops::__pred_iter(_Predicate) [with _Predicate = A::member()::<lambda(int)>]', declared using local type 'A::member()::<lambda(int)>', is used but never defined [-fpermissive]
stdout
Standard output is empty