Commit 7c468aaf68206f0f05fcf6c436ed274da138bdbc

Authored by Jarryd Beck
1 parent 95a48de8

Allow iterator inputs to parse_positional

CHANGELOG.md
... ... @@ -9,6 +9,10 @@ options. The project adheres to semantic versioning.
9 9  
10 10 * Allow integers to have leading zeroes.
11 11  
  12 +### Added
  13 +
  14 +* Iterator inputs to `parse_positional`.
  15 +
12 16 ### Bug Fixes
13 17  
14 18 * Fix a warning about possible loss of data.
... ...
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(&quot;All positional&quot;, &quot;[positional]&quot;)
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  
... ...