mirror of
https://github.com/bminor/binutils-gdb.git
synced 2025-11-16 12:34:43 +00:00
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>
This commit is contained in:
committed by
Simon Marchi
parent
f772ad29ab
commit
99b6de03fe
@@ -30,9 +30,8 @@ struct iterator_range
|
||||
/* Create an iterator_range using BEGIN as the begin iterator.
|
||||
|
||||
Assume that the end iterator can be default-constructed. */
|
||||
template <typename... Args>
|
||||
iterator_range (Args &&...args)
|
||||
: m_begin (std::forward<Args> (args)...)
|
||||
explicit iterator_range (IteratorType begin)
|
||||
: iterator_range (std::move (begin), IteratorType {})
|
||||
{}
|
||||
|
||||
/* Create an iterator range using explicit BEGIN and END iterators. */
|
||||
|
||||
Reference in New Issue
Block a user