36 lines · plain
1.. title:: clang-tidy - readability-uniqueptr-delete-release2 3readability-uniqueptr-delete-release4====================================5 6Replace ``delete <unique_ptr>.release()`` with ``<unique_ptr> = nullptr``.7The latter is shorter, simpler and does not require use of raw pointer APIs.8 9.. code-block:: c++10 11 std::unique_ptr<int> P;12 delete P.release();13 14 // becomes15 16 std::unique_ptr<int> P;17 P = nullptr;18 19Options20-------21 22.. option:: PreferResetCall23 24 If `true`, refactor by calling the reset member function instead of25 assigning to ``nullptr``. Default value is `false`.26 27 .. code-block:: c++28 29 std::unique_ptr<int> P;30 delete P.release();31 32 // becomes33 34 std::unique_ptr<int> P;35 P.reset();36