Search code examples
c++qtqt5

C++ Qt where's the std::unique_ptr Qt version?


So when programming in Qt I like to go with the Qt implementation as far as possible. As far as I've seen there's no Qt version of the std::unique_ptr or is there?

What would be the alternatives that produce the "same" result in Qt if it doesn't exist?


Solution

  • The Qt equivalent to std::unique_ptr is QScopedPointer.

    It's significantly less useful as it doesn't support move semantics, making it closer in utility to C++03 std::auto_ptr (Why is auto_ptr being deprecated?).