You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
/* Getter enabled for all template types other than std::vector and std::list * @throws std::logic_error in case of an invalid argument name * @throws std::logic_error in case of incompatible types */template <typename T = std::string> T get(std::string_view aArgumentName) {
return (*this)[aArgumentName].get<T>();
}
Function is providing a copy of value - but is not const - which leaks this to other classes that have ArgumentParser as a member.
Example of problem:
structprogram_arguments
{
intage() /* const is not possible here */ { return parser.get<int>("age"); }
argparse::ArgumentParser parser;
};
There seems to be no reason besides usage of [] operator for the function not to be const. It could be made const for example by using .at on std::map
The text was updated successfully, but these errors were encountered:
Hello,
Function is providing a copy of value - but is not const - which leaks this to other classes that have
ArgumentParser
as a member.Example of problem:
There seems to be no reason besides usage of
[] operator
for the function not to be const. It could be madeconst
for example by using.at
onstd::map
The text was updated successfully, but these errors were encountered: