This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] Use an std::vector for inline_states


On 2018-04-09 05:10, Pedro Alves wrote:
Hi,

I remembered now that I forgot so point at something that I had wanted
to mention before.

It's that I think that this:

+template <typename T>
+T
+unordered_remove (std::vector<T> &vec, typename std::vector<T>::iterator it)
+{

won't work as is with gdb::def_vector/gdb::byte_vector, because the above assumes std::vector has a single template parameter, while in reality it
has two.

I think this can either be fixed by adding an allocator template parameter
to unordered_remove:

 template<typename T, typename A>
 void
 unordered_erase (std::vector<T, A> &v,
                  typename std::vector<T, A>::iterator pos)

or by making the whole vector/container type a template like in
my example:

 template<typename Vector>
 void
 unordered_erase (Vector &v, typename Vector::iterator pos)

That sounds like a good change, but let's do it as a separate patch (as renaming the functions).

I was wondering if it would also be worthwhile to have an equivalent of std::remove_if that doesn't preserve the order of the remaining elements (which could have been used in this patch).

I pushed my patch in, including the missing usage of unordered_remove that you pointed out in your other message.

Thanks,

Simon


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]