C++ Logo

std-proposals

Advanced search

Re: [std-proposals] Risks of using std::extent on non-built-in array types

From: Andre Kostur <andre_at_[hidden]>
Date: Fri, 13 Dec 2024 09:05:09 -0800
To be fair, there may be 6+ years of code out there already using
std::extent::value (and the concern is updating existing code).

I’m pondering whether suggesting adding a specialization for std::array
would be better. But raises the question if there was a dependency by
someone on extents of std::array returning 0.

On Fri, Dec 13, 2024 at 8:53 AM Thiago Macieira via Std-Proposals <
std-proposals_at_[hidden]> wrote:

> On Friday 13 December 2024 12:09:06 Brasilia Standard Time Yexuan Xiao via
> Std-Proposals wrote:
> > for(std::size_t i{}; i != std::extent_v<arr>; ++i) { /* */ };
>
> Write instead:
>
> for (std::size_t i = 0; i != std::size(arr); ++i)
>
> with arr here being the actual array variable instead of the array type.
>
> --
> Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org
> Principal Engineer - Intel DCAI Platform & System Engineering
>
>
>
> --
> Std-Proposals mailing list
> Std-Proposals_at_[hidden]
> https://lists.isocpp.org/mailman/listinfo.cgi/std-proposals
>

Received on 2024-12-13 17:05:28