vector.h bug?
Alexandre Oliva
oliva@dcc.unicamp.br
Tue Jan 13 01:52:00 GMT 1998
Theodore C Belding writes:
> I'm running egcs-1.0.1 under Redhat linux 5.0 on an i586 laptop. I've run
> across what seems to me a bug in vector.h. Is this a known problem?
> vector<int> v(2,1);
It is a known gotcha in the C++ Standard. From the two viable
constructors that could be selected by overload resolution,
vector<InputIterator=int>(int, int) (if I can abuse template syntax to
explicitly specify the constructor template arguments) is preferred
over vector(unsigned, const int&), because the first is an exact
match, while the second involves integral promotion for the first
argument.
template <class InputIterator>
vector(InputIterator first, InputIterator last);
explicit vector(size_type n, const T& value);
--
Alexandre Oliva
mailto:oliva@dcc.unicamp.br mailto:aoliva@acm.org
http://www.dcc.unicamp.br/~oliva
Universidade Estadual de Campinas, SP, Brasil
More information about the Gcc-bugs
mailing list