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

[SUGGESTION] Make main args usable with ranges #1280

Open
jhugard opened this issue Sep 16, 2024 · 0 comments
Open

[SUGGESTION] Make main args usable with ranges #1280

jhugard opened this issue Sep 16, 2024 · 0 comments

Comments

@jhugard
Copy link

jhugard commented Sep 16, 2024

While toying with hello world, noticed that cpp2:args isn't usable with std::ranges.

Suggesting to update definition to satisfy std::ranges::bidirectional_range, so that the following is possible:

main: (args) = {
    static_assert(std::bidirectional_iterator<cpp2::args::iterator>);
    static_assert(std::ranges::bidirectional_range<cpp2::args>);
    static_assert(std::ranges::viewable_range<cpp2::args>);

    // Output command line arguments, dropping the program name argc[0].
    for args | std::ranges::views::drop(1) do (arg)
    {
        std::cout
            << arg << std::endl;
    }
}

PR inbound...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant