fork download
  1. #include <iostream>
  2. #include <typeinfo>
  3. using namespace std;
  4.  
  5. template<class T> struct wrap { };
  6.  
  7. template<class T>
  8. void bar(T &&value) { std::cout << " vs. " << typeid(wrap<T>).name() << std::endl; }
  9.  
  10. template<class T>
  11. void foo(T &&value) { std::cout << typeid(wrap<T>).name(); return bar(value); }
  12.  
  13. int main()
  14. {
  15. int i = 1;
  16. foo(static_cast<int &>(i));
  17. foo(static_cast<int const &>(i));
  18. foo(static_cast<int &&>(i));
  19. foo(static_cast<int const &&>(i));
  20. }
Success #stdin #stdout 0s 15240KB
stdin
Standard input is empty
stdout
4wrapIRiE vs. 4wrapIRiE
4wrapIRKiE vs. 4wrapIRKiE
4wrapIiE vs. 4wrapIRiE
4wrapIKiE vs. 4wrapIRKiE