fork download
  1. #include <iostream>
  2.  
  3. class logged_creation
  4. {
  5. public:
  6. logged_creation() {std::cout << "default ctor\n";}
  7. logged_creation(const logged_creation &) {std::cout << "copy ctor\n";}
  8. logged_creation(logged_creation &&) {std::cout << "move ctor\n";}
  9. };
  10.  
  11. template <typename T>
  12. class foo
  13. {
  14. public:
  15. void func(T val)
  16. {
  17. T v = std::move(val);
  18. }
  19. };
  20.  
  21. int main()
  22. {
  23. foo<logged_creation> f;
  24. std::cout << "RValue: \n";
  25. f.func(logged_creation());
  26. std::cout << "LValue: \n";
  27. logged_creation i;
  28. f.func(i);
  29. }
  30.  
Success #stdin #stdout 0s 3296KB
stdin
Standard input is empty
stdout
RValue: 
default ctor
move ctor
LValue: 
default ctor
copy ctor
move ctor