This is the mail archive of the
mailing list for the GDB project.
Re: [RFA 01/22] Change selttest.c to use use std::vector
On Mon, Sep 26, 2016 at 10:08:29PM -0600, Tom Tromey wrote:
> This patch changes selftest.c to use std::vector rather than VEC.
> I think this is a small net plus. Because we're using C++03, we
I'd agree, hopefully we can throw VEC in the trash some day. Relatedly
we should probably move gcc's hash table stuff to include/ sooner rather
than later so we can similarly get rid of htab.
> unfortunately don't all the possible benefits here; namely, iterating
I think you missed get in that sentence.
> over a vector is still a pain. For reference, in C++11 the loop would
> be just:
> for (auto f : tests)
its debatable, but imho its not necessarily obvious what the type of the
local is when you use auto to iterate over vectors especially when they
are members or globals like here.
> +static std::vector<self_test_function *> tests;
should we use a pointer to avoid the static initializer?
> - for (i = 0; VEC_iterate (self_test_function_ptr, tests, i, func); ++i)
> + for (std::vector<self_test_function *>::iterator iter = tests.begin ();
> + iter != tests.end ();
> + ++iter)
I believe you can "cheat" here and just use the function pointer type,
because the sane implementation of iterators over vectors is pointers.