Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Simon Marchi <simon.marchi@efficios.com>
To: Tom Tromey <tom@tromey.com>
Cc: gdb-patches@sourceware.org
Subject: Re: [PATCH 2/3] gdbsupport: make filtered_iterator work with pointers
Date: Fri, 29 Aug 2025 13:59:08 -0400	[thread overview]
Message-ID: <6052cd97-efc5-457d-86d2-f600e953ef3c@efficios.com> (raw)
In-Reply-To: <875xe6utyx.fsf@tromey.com>



On 2025-08-29 09:40, Tom Tromey wrote:
> I also wonder what this constructor is even needed for since it seems
> like a filtered iterator should just wrap an ordinary one anyway.

To answer to that specifically: filtered_iterator needs to know the end
in addition to the begin, so that it knows when to stop advancing, in
operator++.

The goal of these variadic constructors is so that you don't need to be
explicit about all the iterator layers.  To build a
filtered_iterator<my_iterator>, instead of writing:

    filtered_iterator<my_iterator> (my_iterator (arg1, arg2))

You can write:

    filtered_iterator<my_iterator> (arg1, arg2);

In my experience, it has been very confusing to work with these
iterators though.  Compilation failures are hard to debug, like finding
which of the N layers of iterator is not happy.  The complicated
template error messages certainly don't help.  So I would propose to
ditch all those, and just have explicit and straightforward constructors
like the one I add in this patch.  The code that uses these iterators
will be more explicit and larger, but typically we only write it once in
a factory function (e.g. all_threads).

Simon

  parent reply	other threads:[~2025-08-29 18:00 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-08-28 15:10 [PATCH 1/3] gdb/objfiles: make objfile::sections yield references Simon Marchi
2025-08-28 15:10 ` [PATCH 2/3] gdbsupport: make filtered_iterator work with pointers Simon Marchi
2025-08-29 13:40   ` Tom Tromey
2025-08-29 16:00     ` Simon Marchi
2025-08-29 17:39       ` Tom Tromey
2025-08-29 20:11         ` Simon Marchi
2025-09-03  2:01       ` Tom Tromey
2025-08-29 17:59     ` Simon Marchi [this message]
2025-08-29 18:19       ` Tom Tromey
2025-08-28 15:10 ` [PATCH 3/3] gdb/objfiles: use filtered_iterator as objfile::section_iterator Simon Marchi
2025-08-29 13:42   ` Tom Tromey
2025-08-29 16:06     ` Simon Marchi
2025-08-29 20:22       ` Simon Marchi
2025-08-29 13:34 ` [PATCH 1/3] gdb/objfiles: make objfile::sections yield references Tom Tromey
2025-08-29 15:47   ` 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=6052cd97-efc5-457d-86d2-f600e953ef3c@efficios.com \
    --to=simon.marchi@efficios.com \
    --cc=gdb-patches@sourceware.org \
    --cc=tom@tromey.com \
    /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