mirror of
https://github.com/KeqingMoe/argparse.git
synced 2025-07-04 07:04:39 +00:00
Index arguments without storing their names twice
This commit is contained in:
parent
3f949fc3f1
commit
9007958c1f
@ -39,6 +39,7 @@ SOFTWARE.
|
|||||||
#include <sstream>
|
#include <sstream>
|
||||||
#include <stdexcept>
|
#include <stdexcept>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
#include <string_view>
|
||||||
#include <tuple>
|
#include <tuple>
|
||||||
#include <type_traits>
|
#include <type_traits>
|
||||||
#include <variant>
|
#include <variant>
|
||||||
@ -581,13 +582,13 @@ private:
|
|||||||
|
|
||||||
void index_argument(list_iterator argIt) {
|
void index_argument(list_iterator argIt) {
|
||||||
for (auto &mName : std::as_const(argIt->mNames))
|
for (auto &mName : std::as_const(argIt->mNames))
|
||||||
mArgumentMap.insert_or_assign(mName, argIt);
|
mArgumentMap.emplace(mName, argIt);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string mProgramName;
|
std::string mProgramName;
|
||||||
std::list<Argument> mPositionalArguments;
|
std::list<Argument> mPositionalArguments;
|
||||||
std::list<Argument> mOptionalArguments;
|
std::list<Argument> mOptionalArguments;
|
||||||
std::map<std::string, list_iterator, std::less<>> mArgumentMap;
|
std::map<std::string_view, list_iterator, std::less<>> mArgumentMap;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace argparse
|
} // namespace argparse
|
||||||
|
Loading…
Reference in New Issue
Block a user