fork download
  1. #include <utility>
  2. #include <string>
  3.  
  4. template<typename T>
  5. void X(T&& x)
  6. {
  7. auto y = std::forward(x);
  8. }
  9.  
  10. int main()
  11. {
  12. std::string x;
  13. X(x);
  14. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp: In instantiation of ‘void X(T&&) [with T = std::basic_string<char>&]’:
prog.cpp:13:5:   required from here
prog.cpp:7:28: error: no matching function for call to ‘forward(std::basic_string<char>&)’
     auto y = std::forward(x);
                            ^
prog.cpp:7:28: note: candidates are:
In file included from /usr/include/c++/4.8/bits/stl_pair.h:59:0,
                 from /usr/include/c++/4.8/utility:70,
                 from prog.cpp:1:
/usr/include/c++/4.8/bits/move.h:76:5: note: template<class _Tp> constexpr _Tp&& std::forward(typename std::remove_reference<_From>::type&)
     forward(typename std::remove_reference<_Tp>::type& __t) noexcept
     ^
/usr/include/c++/4.8/bits/move.h:76:5: note:   template argument deduction/substitution failed:
prog.cpp:7:28: note:   couldn't deduce template parameter ‘_Tp’
     auto y = std::forward(x);
                            ^
In file included from /usr/include/c++/4.8/bits/stl_pair.h:59:0,
                 from /usr/include/c++/4.8/utility:70,
                 from prog.cpp:1:
/usr/include/c++/4.8/bits/move.h:87:5: note: template<class _Tp> constexpr _Tp&& std::forward(typename std::remove_reference<_From>::type&&)
     forward(typename std::remove_reference<_Tp>::type&& __t) noexcept
     ^
/usr/include/c++/4.8/bits/move.h:87:5: note:   template argument deduction/substitution failed:
prog.cpp:7:28: note:   couldn't deduce template parameter ‘_Tp’
     auto y = std::forward(x);
                            ^
stdout
Standard output is empty