fork download
  1. #include <iostream>
  2. #include <utility>
  3.  
  4. class X {
  5. int m_x;
  6. public:
  7. X () = delete;
  8. X (int x) : m_x (x) { std::cout << "X::X(int)" << std::endl; }
  9. X (X&& src) : m_x (src.m_x) { src.m_x = -1; std::cout << "X::X(X&&)" << std::endl; }
  10. ~X () { std::cout << "X::~X, m_x = " << m_x << std::endl; }
  11. };
  12.  
  13. void foo (X x) {
  14.  
  15. }
  16.  
  17.  
  18. int main() {
  19. X x (42);
  20. foo (std::move (x));
  21. return 0;
  22. }
Success #stdin #stdout 0s 16064KB
stdin
Standard input is empty
stdout
X::X(int)
X::X(X&&)
X::~X, m_x = 42
X::~X, m_x = -1