fork(1) download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. template<class T>
  5. void only_rvals(T&) = delete;
  6.  
  7. template<class T>
  8. void only_rvals(T&&) { }
  9.  
  10. int main() {
  11. int i;
  12. only_rvals(i);
  13. only_rvals(6);
  14. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp: In function ‘int main()’:
prog.cpp:12:17: error: call of overloaded ‘only_rvals(int&)’ is ambiguous
     only_rvals(i);
                 ^
prog.cpp:12:17: note: candidates are:
prog.cpp:5:6: note: void only_rvals(T&) [with T = int] <deleted>
 void only_rvals(T&) = delete;
      ^
prog.cpp:8:6: note: void only_rvals(T&&) [with T = int&]
 void only_rvals(T&&) { }
      ^
stdout
Standard output is empty