#include <utility> template <class T> void foo(T& x) {} int main() { int i = 3; foo(std::move(i)); int& y = std::move(i); return 0; }
Standard input is empty
prog.cpp: In function ‘int main()’: prog.cpp:9:18: error: cannot bind non-const lvalue reference of type ‘int&’ to an rvalue of type ‘std::remove_reference<int&>::type’ {aka ‘int’} foo(std::move(i)); ~~~~~~~~~^~~ prog.cpp:4:6: note: initializing argument 1 of ‘void foo(T&) [with T = int]’ void foo(T& x) ^~~ prog.cpp:11:23: error: cannot bind non-const lvalue reference of type ‘int&’ to an rvalue of type ‘std::remove_reference<int&>::type’ {aka ‘int’} int& y = std::move(i); ~~~~~~~~~^~~
Standard output is empty