Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

scan_list_ex: unable to use separator when scanning list of strings #84

Closed
phisko opened this issue Mar 6, 2023 · 1 comment
Closed

Comments

@phisko
Copy link

phisko commented Mar 6, 2023

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.

@eliaskosunen
Copy link
Owner

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.

@eliaskosunen eliaskosunen closed this as not planned Won't fix, can't repro, duplicate, stale May 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants