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