Skip to content

Latest commit

 

History

History
12 lines (10 loc) · 263 Bytes

move-ctor.md

File metadata and controls

12 lines (10 loc) · 263 Bytes

Move Contructor

Move ctors steal or copy ownership of dynamically created resources(file descriptors, TCP sockets, threads) held by the argument

class A {
  string s;
  int n;
  public:
  A(A&& o) : s(std::move(o.s)), n(std::exchange(o.n, 0)) {}
}