mirror of
https://github.com/KeqingMoe/argparse.git
synced 2025-07-04 15:14:39 +00:00
Make use of move semantics
This commit is contained in:
parent
1eadf94438
commit
bef90a8d4f
@ -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" };
|
||||||
|
Loading…
Reference in New Issue
Block a user