Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Tom Tromey <tom@tromey.com>
To: Simon Marchi <simon.marchi@efficios.com>
Cc: gdb-patches@sourceware.org,  Simon Marchi <simon.marchi@polymtl.ca>
Subject: Re: [PATCH 1/3] gdbsupport: add gdb::enumerate util
Date: Fri, 20 Feb 2026 13:47:59 -0700	[thread overview]
Message-ID: <87zf53ywe8.fsf@tromey.com> (raw)
In-Reply-To: <20260220202002.860008-1-simon.marchi@efficios.com> (Simon Marchi's message of "Fri, 20 Feb 2026 15:19:41 -0500")

>>>>> "Simon" == Simon Marchi <simon.marchi@efficios.com> writes:

Simon> From: Simon Marchi <simon.marchi@polymtl.ca>
Simon> Add a "enumerate" utility, that acts pretty much like Python's
Simon> enumerate().  It makes the code slightly nicer, for when you would
Simon> otherwise need to handle the counter by hand.

Very handy.

Simon> +namespace gdb
Simon> +{
Simon> +

I suggest adding more namespaces and calling this
gdb::ranges::views::enumerate.  Then when gdb uses C++23, we can perhaps
just s/gdb/std/ and not reformat everything.

https://en.cppreference.com/w/cpp/ranges/enumerate_view.html

... in particular note (2)

I guess we could go the other way but I tend to think it's better in the
end to just use the standard names and not supply renamings of things.

Simon> +template<typename T>
Simon> +struct enumerated_element
Simon> +{
Simon> +  std::size_t index;
Simon> +  T value;
Simon> +};

C++23 uses a tuple here.

It also uses a reference but I am not sure if that matters for us.

Tom

  parent reply	other threads:[~2026-02-20 20:48 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-02-20 20:19 Simon Marchi
2026-02-20 20:19 ` [PATCH 2/3] gdb/dwarf: use enumerate in index-write.c Simon Marchi
2026-02-20 20:19 ` [PATCH 3/3] gdb: use enumerate in gdbtypes.c Simon Marchi
2026-02-20 20:47 ` Tom Tromey [this message]
2026-02-21  0:58   ` [PATCH 1/3] gdbsupport: add gdb::enumerate util Simon Marchi
2026-02-21  1:18 ` [PATCH v2 1/3] gdbsupport: add gdb::ranges::views::enumerate util simon.marchi
2026-02-21  1:18   ` [PATCH v2 2/3] gdb/dwarf: use enumerate in index-write.c simon.marchi
2026-02-21  1:19   ` [PATCH v2 3/3] gdb: use enumerate in gdbtypes.c simon.marchi
2026-03-14 17:32   ` [PATCH v2 1/3] gdbsupport: add gdb::ranges::views::enumerate util Simon Marchi
2026-04-16 19:52   ` Simon Marchi

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87zf53ywe8.fsf@tromey.com \
    --to=tom@tromey.com \
    --cc=gdb-patches@sourceware.org \
    --cc=simon.marchi@efficios.com \
    --cc=simon.marchi@polymtl.ca \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox