Skip to content

[clang-tidy] modernize-loop-convert for pointer and size #144475

Open
@lcsondes

Description

@lcsondes

When working with a C API, I often receive arrays as a separate pointer and size. I'd like this pattern to be supported by modernize-loop-convert:

void foo(int* array, int size)
{
    for(int i = 0; i < size; i++)
        std::cout << array[i];
}

To become something like this:

void foo(int* array, int size)
{
    for(int i : std::span(array, size))
        std::cout << i;
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions