size_t can be assigned -1?

On Wed, Mar 1, 2023 at 12:50 AM Frederick Virchanza Gotham via Std-Proposals <std-proposals@lists.isocpp.org> wrote:
Sometimes I write code like this:

    size_t i = -1;
    for ( auto const &e : some_container )
    {
        ++i;
        DoSomeProcessing(e, i);
    }

It would be nice if range-based for loops had an implicit counter
variable, so that the above code snippet could simply be written as:

    for ( auto const &e : some_container )
    {
        DoSomeProcessing(e, __i);
    }

I propose that this would work even with containers that don't allow
random access.
--
Std-Proposals mailing list
Std-Proposals@lists.isocpp.org
https://lists.isocpp.org/mailman/listinfo.cgi/std-proposals