mirror of
https://github.com/bminor/binutils-gdb.git
synced 2025-11-16 04:24:43 +00:00
gdbsupport: remove variadicity from basic_safe_iterator constructors
Change the constructors to accept `Iterator` objects directly. This requires the callers to explicitly pass `Iterator` object (unless perhaps `Iterator` has a non-explicit one-argument constructor. The rationale is the same as the previous patch: make the code easier to follow and make it easier to fix build errors, at the expense of making callers more explicit. Change-Id: Icd2a4ef971456ca250f96227a9b83c935d619451 Approved-By: Tom Tromey <tom@tromey.com>
This commit is contained in:
@@ -794,9 +794,10 @@ all_non_exited_threads (process_stratum_target *proc_target = nullptr,
|
||||
inline all_threads_safe_range
|
||||
all_threads_safe ()
|
||||
{
|
||||
all_threads_safe_iterator begin (all_threads_iterator::begin_t {});
|
||||
all_threads_iterator begin (all_threads_iterator::begin_t {});
|
||||
all_threads_safe_iterator safe_begin (std::move (begin));
|
||||
|
||||
return all_threads_safe_range (std::move (begin));
|
||||
return all_threads_safe_range (std::move (safe_begin));
|
||||
}
|
||||
|
||||
extern int thread_count (process_stratum_target *proc_target);
|
||||
|
||||
@@ -502,9 +502,10 @@ public:
|
||||
*/
|
||||
inline safe_inf_threads_range threads_safe ()
|
||||
{
|
||||
safe_inf_threads_iterator begin (this->thread_list.begin ());
|
||||
inf_threads_iterator begin (this->thread_list.begin ());
|
||||
safe_inf_threads_iterator safe_begin (std::move (begin));
|
||||
|
||||
return safe_inf_threads_range (std::move (begin));
|
||||
return safe_inf_threads_range (std::move (safe_begin));
|
||||
}
|
||||
|
||||
/* Find (non-exited) thread PTID of this inferior. */
|
||||
@@ -832,9 +833,10 @@ extern intrusive_list<inferior> inferior_list;
|
||||
inline all_inferiors_safe_range
|
||||
all_inferiors_safe ()
|
||||
{
|
||||
all_inferiors_safe_iterator begin (nullptr, inferior_list);
|
||||
all_inferiors_iterator begin (nullptr, inferior_list);
|
||||
all_inferiors_safe_iterator safe_begin (std::move (begin));
|
||||
|
||||
return all_inferiors_safe_range (std::move (begin));
|
||||
return all_inferiors_safe_range (std::move (safe_begin));
|
||||
}
|
||||
|
||||
/* Returns a range representing all inferiors, suitable to use with
|
||||
|
||||
@@ -50,30 +50,24 @@ public:
|
||||
typedef typename Iterator::iterator_category iterator_category;
|
||||
typedef typename Iterator::difference_type difference_type;
|
||||
|
||||
/* Construct the begin iterator using the given arguments; the end iterator is
|
||||
default constructed. */
|
||||
template<typename... Args>
|
||||
explicit basic_safe_iterator (Args &&...args)
|
||||
: m_it (std::forward<Args> (args)...),
|
||||
m_next (m_it)
|
||||
{
|
||||
if (m_it != m_end)
|
||||
++m_next;
|
||||
}
|
||||
/* Construct the iterator using the underlying iterator BEGIN; the end
|
||||
iterator is default constructed. */
|
||||
explicit basic_safe_iterator (Iterator begin)
|
||||
: basic_safe_iterator (std::move (begin), Iterator {})
|
||||
{}
|
||||
|
||||
/* Construct the iterator using the first argument, and construct
|
||||
the end iterator using the second argument. */
|
||||
template<typename Arg>
|
||||
explicit basic_safe_iterator (Arg &&arg, Arg &&arg2)
|
||||
: m_it (std::forward<Arg> (arg)),
|
||||
/* Construct the iterator using the underlying iterators BEGIN and END. */
|
||||
basic_safe_iterator (Iterator begin, Iterator end)
|
||||
: m_it (std::move (begin)),
|
||||
m_next (m_it),
|
||||
m_end (std::forward<Arg> (arg2))
|
||||
m_end (std::move (end))
|
||||
{
|
||||
if (m_it != m_end)
|
||||
++m_next;
|
||||
}
|
||||
|
||||
/* Create a one-past-end iterator. */
|
||||
/* Create a one-past-end iterator. The underlying end iterator is obtained
|
||||
by default-constructing. */
|
||||
basic_safe_iterator ()
|
||||
{}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user