Commit 7c468aaf68206f0f05fcf6c436ed274da138bdbc
1 parent
95a48de8
Allow iterator inputs to parse_positional
Showing
3 changed files
with
13 additions
and
1 deletions
CHANGELOG.md
include/cxxopts.hpp
| ... | ... | @@ -1255,6 +1255,12 @@ namespace cxxopts |
| 1255 | 1255 | void |
| 1256 | 1256 | parse_positional(std::initializer_list<std::string> options); |
| 1257 | 1257 | |
| 1258 | + template <typename Iterator> | |
| 1259 | + void | |
| 1260 | + parse_positional(Iterator begin, Iterator end) { | |
| 1261 | + parse_positional(std::vector<std::string>{begin, end}); | |
| 1262 | + } | |
| 1263 | + | |
| 1258 | 1264 | std::string |
| 1259 | 1265 | help(const std::vector<std::string>& groups = {""}) const; |
| 1260 | 1266 | ... | ... |
test/options.cpp
| ... | ... | @@ -145,7 +145,9 @@ TEST_CASE("All positional", "[positional]") |
| 145 | 145 | auto argc = av.argc(); |
| 146 | 146 | auto argv = av.argv(); |
| 147 | 147 | |
| 148 | - options.parse_positional({"positional"}); | |
| 148 | + std::vector<std::string> pos_names = {"positional"}; | |
| 149 | + | |
| 150 | + options.parse_positional(pos_names.begin(), pos_names.end()); | |
| 149 | 151 | |
| 150 | 152 | auto result = options.parse(argc, argv); |
| 151 | 153 | ... | ... |