fork download
  1. #include <iostream>
  2. #include <algorithm>
  3. #include <vector>
  4. using namespace std;
  5.  
  6. class Foo
  7. {
  8. public:
  9. Foo()
  10. {
  11.  
  12. }
  13.  
  14. Foo(Foo &)
  15. {
  16. std::cout <<"!";
  17. }
  18.  
  19. Foo(Foo &&)
  20. {
  21. std::cout << "!!";
  22. }
  23. };
  24.  
  25. int main() {
  26. std::vector<Foo> v(1);
  27. std::generate(v.begin(), v.end(), [](){return Foo();});
  28. return 0;
  29. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
In file included from /usr/include/c++/8/algorithm:62,
                 from prog.cpp:2:
/usr/include/c++/8/bits/stl_algo.h: In instantiation of ‘void std::generate(_FIter, _FIter, _Generator) [with _FIter = __gnu_cxx::__normal_iterator<Foo*, std::vector<Foo> >; _Generator = main()::<lambda()>]’:
prog.cpp:27:55:   required from here
/usr/include/c++/8/bits/stl_algo.h:4436:11: error: use of deleted function ‘constexpr Foo& Foo::operator=(const Foo&)’
  *__first = __gen();
  ~~~~~~~~~^~~~~~~~~
prog.cpp:6:7: note: ‘constexpr Foo& Foo::operator=(const Foo&)’ is implicitly declared as deleted because ‘Foo’ declares a move constructor or move assignment operator
 class Foo
       ^~~
stdout
Standard output is empty