News for hackers. Stuff that matters.
Re:Why RAII rocks by TheCoelacanth on Thursday April 23, 2015 @03:18PM (#9429153)
There's also such a thing as move constructors, so that you can pass ownership to somewhere else and have it be deleted there.

For instance,

  std::unique_ptr<X> f () {
    return std::make_unique<X>();
  }

  void h (std::unique_ptr<X> x) {
    x->doSomething();
    // x is released after this function returns
  }

  void g () {
    auto x = f();
    h(std::move(x));
  }

There are no comments on this comment yet.