fork download
  1. #include <utility>
  2.  
  3. template <class T>
  4. void foo(T& x)
  5. {}
  6.  
  7. int main() {
  8. int i = 3;
  9. foo(std::move(i));
  10.  
  11. int& y = std::move(i);
  12. return 0;
  13. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
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);
              ~~~~~~~~~^~~
stdout
Standard output is empty