#include <iostream> using namespace std; struct Foo { template <typename U> Foo(U&& i) : i(i){} Foo(const Foo& rhs) { std::cout <<"copy"; } int i; }; int main() { Foo f(42); auto f2(f); return 0; }
Standard input is empty
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){} ^
Standard output is empty