Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Simon Marchi <simon.marchi@polymtl.ca>
To: Pedro Alves <palves@redhat.com>
Cc: gdb-patches@sourceware.org
Subject: Re: [PATCH] Use an std::vector for inline_states
Date: Mon, 09 Apr 2018 19:45:00 -0000	[thread overview]
Message-ID: <18cfea83a1c38452412c906452ad38ae@polymtl.ca> (raw)
In-Reply-To: <5d1e75f3-6f53-9da8-ffe5-95ef6d7795ee@redhat.com>

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


      reply	other threads:[~2018-04-09 19:45 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-04-07 14:42 Simon Marchi
2018-04-07 19:28 ` Pedro Alves
2018-04-07 21:13   ` Simon Marchi
2018-04-07 23:21   ` Simon Marchi
2018-04-08 17:29     ` Pedro Alves
2018-04-09  9:10       ` Pedro Alves
2018-04-09 19:45         ` Simon Marchi [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=18cfea83a1c38452412c906452ad38ae@polymtl.ca \
    --to=simon.marchi@polymtl.ca \
    --cc=gdb-patches@sourceware.org \
    --cc=palves@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox