This is the mail archive of the
libstdc++@gcc.gnu.org
mailing list for the libstdc++ project.
Re: Empty vector::push_back()?
On Tue, Feb 26, 2002 at 02:26:49AM +0100, Gabriel Dos Reis wrote:
> Benjamin Kosnik <bkoz@redhat.com> writes:
>
> | > I dunno :-)
> |
> | > It isn't standard.
> |
> | Maybe it should be removed then?
>
> I contemplated that possibility, but I can't anticipate the amount of
> code that will break and the impact it will have. On the other hand, I
> find Phil's idea of having a hook into the diagnostic machinery
> attractive -- even though I think we should not abuse of it.
>
> What is your take?
Ideally, I would like to get a warning if it is called from code that
was compiled "-pedantic". If that's too hard, it would suffice for
it to be an error in that case.
I recommend adding a comment in its place that suggests replacing uses
of "v.push_back()" with "v.resize(v.size()+1)". This might be added
to the docs as well.
Nathan Myers
ncm at cantrip dot org