If you pass around span instead of pointer and length then it becomes less error prone and shorter - https://godbolt.org/z/Y4WqPM3r4

#include <span>

int get();

void fun(int* p, unsigned len)
{
    for ( unsigned i = 0u; i < len; ++i ) *p++ = get();
}

void more_fun(int* p, unsigned len)
{
    for (auto& e : std::span{p, len}) e = get();
}

void best_fun(std::span<int> buff)
{
    for (auto& e : buff) e = get();

On Mon, Oct 23, 2023 at 12:18 PM Frederick Virchanza Gotham via Std-Proposals <std-proposals@lists.isocpp.org> wrote:
What if the following:

    for ( usigned i = 0u; i < len; ++i ) *p++ = Get();

Could be written as simply:

    for ( len ) *p++ = Get();
--
Std-Proposals mailing list
Std-Proposals@lists.isocpp.org
https://lists.isocpp.org/mailman/listinfo.cgi/std-proposals