Skip to content

[SUGGESTION] Make main args usable with ranges #1280

Open
@jhugard

Description

@jhugard

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...

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions