diff options
author | Marc Chevrier <marc.chevrier@gmail.com> | 2019-07-04 16:14:22 (GMT) |
---|---|---|
committer | Marc Chevrier <marc.chevrier@gmail.com> | 2019-07-14 13:37:30 (GMT) |
commit | 1591f138f1a40fccdde7fb2796ee2d2d8f3f97bb (patch) | |
tree | 4db8440a950a88b7c15ea43218f98f61775bf889 /Source/cmDisallowedCommand.h | |
parent | d9b2c7dae242868f13fc366773fb09448da26e8d (diff) | |
download | CMake-1591f138f1a40fccdde7fb2796ee2d2d8f3f97bb.zip CMake-1591f138f1a40fccdde7fb2796ee2d2d8f3f97bb.tar.gz CMake-1591f138f1a40fccdde7fb2796ee2d2d8f3f97bb.tar.bz2 |
modernize: manage cmCommand instances using unique_ptr.
Diffstat (limited to 'Source/cmDisallowedCommand.h')
-rw-r--r-- | Source/cmDisallowedCommand.h | 19 |
1 files changed, 11 insertions, 8 deletions
diff --git a/Source/cmDisallowedCommand.h b/Source/cmDisallowedCommand.h index d85c00f..eed59ca 100644 --- a/Source/cmDisallowedCommand.h +++ b/Source/cmDisallowedCommand.h @@ -6,8 +6,11 @@ #include "cmConfigure.h" // IWYU pragma: keep #include <string> +#include <utility> #include <vector> +#include "cm_memory.hxx" + #include "cmCommand.h" #include "cmPolicies.h" @@ -16,20 +19,20 @@ class cmExecutionStatus; class cmDisallowedCommand : public cmCommand { public: - cmDisallowedCommand(cmCommand* command, cmPolicies::PolicyID policy, - const char* message) - : Command(command) + cmDisallowedCommand(std::unique_ptr<cmCommand> command, + cmPolicies::PolicyID policy, const char* message) + : Command(std::move(command)) , Policy(policy) , Message(message) { } - ~cmDisallowedCommand() override { delete this->Command; } + ~cmDisallowedCommand() override = default; - cmCommand* Clone() override + std::unique_ptr<cmCommand> Clone() override { - return new cmDisallowedCommand(this->Command->Clone(), this->Policy, - this->Message); + return cm::make_unique<cmDisallowedCommand>(this->Command->Clone(), + this->Policy, this->Message); } bool InitialPass(std::vector<std::string> const& args, @@ -40,7 +43,7 @@ public: bool HasFinalPass() const override { return this->Command->HasFinalPass(); } private: - cmCommand* Command; + std::unique_ptr<cmCommand> Command; cmPolicies::PolicyID Policy; const char* Message; }; |