fork(6) download
  1. #include <iostream>
  2. #include <type_traits>
  3.  
  4. template <typename T>
  5. struct helper
  6. {
  7. void f(T &&)
  8. {
  9. std::cout << "&&" << std::endl;
  10. }
  11.  
  12. void f(const T&)
  13. {
  14. std::cout << "const &" << std::endl;
  15. }
  16.  
  17. };
  18.  
  19. template <typename T>
  20. void f(T &&t)
  21. {
  22. helper<typename std::decay<T>::type>().f(std::forward<T>(t));
  23. }
  24.  
  25.  
  26. int main()
  27. {
  28. int i;
  29. f(i);
  30. f(i + 1);
  31. }
Success #stdin #stdout 0s 3140KB
stdin
Standard input is empty
stdout
const &
&&