Re: [PATCH v2 1/3] gdbsupport: add gdb::ranges::views::enumerate util

Simon Marchi
2026-04-16T19:53:18Z

On 2/20/26 8:18 PM, simon.marchi@polymtl.ca wrote:
> From: Simon Marchi <simon.marchi@polymtl.ca>
>
> Add a "enumerate" utility, that acts pretty much like Python's
> enumerate(). It makes the code slightly nicer, for when you would
> otherwise need to handle the counter by hand.
>
> It can be used like this:
>
> std::vector<int> my_vector;
> for (auto [i, val] : gdb::ranges::views::enumerate (my_vector))
> ...
>
> `i` will hold the 0-based index of the current iteration, and `val` will
> be a reference to the value of the current iteration.
>
> The name is chosen to match std::ranges::views::enumerate from C++23,
> making it easy to switch to that eventually.
>
> Change-Id: I1870ab50537bcf54bba44a30a0b01ab397be16e3

I pushed all 3 patches of this series.

Simon