Make use of move semantics

This commit is contained in:
Stephan van Veen 2019-05-09 18:06:56 +02:00
parent 1eadf94438
commit bef90a8d4f

View File

@ -99,18 +99,18 @@ public:
} }
Argument& default_value(std::any aDefaultValue) { Argument& default_value(std::any aDefaultValue) {
mDefaultValue = aDefaultValue; mDefaultValue = std::move(aDefaultValue);
return *this; return *this;
} }
Argument& implicit_value(std::any aImplicitValue) { Argument& implicit_value(std::any aImplicitValue) {
mImplicitValue = aImplicitValue; mImplicitValue = std::move(aImplicitValue);
mNumArgs = 0; mNumArgs = 0;
return *this; return *this;
} }
Argument& action(std::function<std::any(const std::string&)> aAction) { Argument& action(std::function<std::any(const std::string&)> aAction) {
mAction = aAction; mAction = std::move(aAction);
return *this; return *this;
} }
@ -281,8 +281,8 @@ public:
class ArgumentParser { class ArgumentParser {
public: public:
ArgumentParser(const std::string& aProgramName = "") : explicit ArgumentParser(std::string aProgramName = "") :
mProgramName(aProgramName), mProgramName(std::move(aProgramName)),
mNextPositionalArgument(0) { mNextPositionalArgument(0) {
std::shared_ptr<Argument> tArgument = std::make_shared<Argument>(); std::shared_ptr<Argument> tArgument = std::make_shared<Argument>();
tArgument->mNames = { "-h", "--help" }; tArgument->mNames = { "-h", "--help" };