fork(4) download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. template <typename T>
  5. void Foo(T&& t) {}
  6.  
  7. template <template <typename, typename...> typename C, typename T, typename... Rest>
  8. void Bar(C<T, Rest...>&& c) { }
  9.  
  10. int main() {
  11. int i = 0;
  12. Foo(i);
  13.  
  14. string str;
  15. Bar(str);
  16.  
  17. return 0;
  18. }
Compilation error #stdin compilation error #stdout 0s 5508KB
stdin
Standard input is empty
compilation info
prog.cpp: In function ‘int main()’:
prog.cpp:15:6: error: cannot bind rvalue reference of type ‘std::__cxx11::basic_string<char>&&’ to lvalue of type ‘std::__cxx11::string’ {aka ‘std::__cxx11::basic_string<char>’}
  Bar(str);
      ^~~
prog.cpp:8:6: note:   initializing argument 1 of ‘void Bar(C<T, Rest ...>&&) [with C = std::__cxx11::basic_string; T = char; Rest = {std::char_traits<char>, std::allocator<char>}]’
 void Bar(C<T, Rest...>&& c) { }
      ^~~
stdout
Standard output is empty