scan_list_ex: unable to use separator when scanning list of strings
Closed this issue · 1 comments
Passing a separator to scan_list_ex
when scanning a list of strings will have no effect, because the separator will be consumed by the string scanner.
In the following example:
int main() {
std::vector<std::string> vs;
const auto result = scn::scan_list_ex("0, 42, 84", vs, scn::list_separator(','));
for (const auto & s : vs)
std::cout << s << std::endl;
return 0;
}
vs
will contain [ "0,", "42,", "84" ]
(see how the commas have been included in each string).
On a related note, I've written a scanner specialization for ranges that parse them with the same formats as those generated by fmt/ranges.h (see the tests). Would you be interested in adding this to the library (perhaps as scn/ranges.h
, to follow fmt
's architecture)? If so I could look into opening a PR.
This is no longer relevant: scan_list
is no longer available. An experimental implementation of scanning of ranges is also available in <scn/ranges.h>
. Closing.