]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commit
gdbsupport: remove variadicity from iterator_range constructor
authorSimon Marchi <simon.marchi@polymtl.ca>
Wed, 3 Sep 2025 14:50:02 +0000 (10:50 -0400)
committerSimon Marchi <simon.marchi@efficios.com>
Tue, 7 Oct 2025 20:22:15 +0000 (16:22 -0400)
commit99b6de03fe4ac1518e68ac42c124dd5fa1704397
tree90af9ad9f9fb1db9ecd783d6f1e125ea85855839
parentf772ad29ab606742aa00db2de62e8983b5ebce0a
gdbsupport: remove variadicity from iterator_range constructor

There are two ways to build an iterator_range:

 - Using the variadic constructor, where the arguments you pass are used
   to construct the "begin" underlying iterator.  The "end" iterator is
   obtained by default-constructing the underlying iterator.

 - Using the other constructor, by explicitly providing the "begin" and
   "end" iterators.

My experience is that using the variadic constructor is very confusing,
especially when you have multiple layers of iterator wrappers.  It's not
obvious where the arguments you provide end up.  When you have a
compilation error, it is hard to decipher.

I propose to remove the variadicity of the first constructor of
iterator_range, and subsequently of the other iterator wrappers.  This
requires callers to be more verbose, explicitly instantiate all the
layers.  But since we only instantiate these iterator wrappers in
factory functions, I think it's fine.  If there is a compilation error,
it will be much easier to find and fix the problem.

Using the new one-argument constructor, it is still assumed that the end
iterator can be obtained by default-constructing the underlying iterator
type, which I think is fine and not too confusing.

Change-Id: I54d6fdef18bcd7e308825064e0fc18fadd7ca717
Approved-By: Tom Tromey <tom@tromey.com>
13 files changed:
gdb/block.c
gdb/block.h
gdb/dwarf2/die.h
gdb/gdb_bfd.h
gdb/gdbthread.h
gdb/inferior.h
gdb/linux-nat.c
gdb/objfiles.h
gdb/progspace.h
gdb/psymtab.h
gdb/symtab.h
gdb/ui.h
gdbsupport/iterator-range.h