fork(2) download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. struct Foo {
  5.  
  6. template <typename U>
  7. Foo(U&& i) : i(i){}
  8.  
  9. Foo(const Foo& rhs) {
  10. std::cout <<"copy";
  11. }
  12.  
  13. int i;
  14. };
  15.  
  16. int main() {
  17.  
  18. Foo f(42);
  19. auto f2(f);
  20.  
  21. return 0;
  22. }
Compilation error #stdin compilation error #stdout 0s 4356KB
stdin
Standard input is empty
compilation info
prog.cpp: In instantiation of ‘Foo::Foo(U&&) [with U = Foo&]’:
prog.cpp:19:11:   required from here
prog.cpp:7:18: error: cannot convert ‘Foo’ to ‘int’ in initialization
  Foo(U&& i) : i(i){}
                  ^
stdout
Standard output is empty