fork(1) download
  1. #include <iostream>
  2. #include <utility>
  3.  
  4. void bar(int&) {std::cout << "int&" << std::endl;}
  5. void bar(const int&) {std::cout << "const int&" << std::endl;}
  6. void bar(int&&) {std::cout << "int&&" << std::endl;}
  7.  
  8. template <typename... Args>
  9. void foo(Args&&... args)
  10. {
  11. return bar(std::forward<Args>(args)...);
  12. }
  13.  
  14. int main()
  15. {
  16. int i = 0;
  17. const int ci = 0;
  18.  
  19. foo(i);
  20. foo(ci);
  21. foo(5);
  22. }
Success #stdin #stdout 0s 2884KB
stdin
Standard input is empty
stdout
int&
const int&
int&&