fork download
  1. #include <iostream>
  2. #include <utility>
  3. #include <type_traits>
  4.  
  5. class value
  6. {
  7. public:
  8. value() {}
  9. value(value const&)
  10. {
  11. std::cout << "value(copy constructor)\n";
  12. }
  13. value(value&&)
  14. {
  15. std::cout << "value(move constructor)\n";
  16. }
  17. };
  18.  
  19. template <typename T>
  20. void push_back(T&& a_t)
  21. {
  22. new typename std::remove_reference<T>::type(std::forward<T>(a_t));
  23. }
  24.  
  25. int main()
  26. {
  27. push_back(value());
  28. value v;
  29. push_back(v);
  30. return 0;
  31. }
  32.  
Success #stdin #stdout 0s 2984KB
stdin
Standard input is empty
stdout
value(move constructor)
value(copy constructor)