This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


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

Re: egcs-1.0.2 STL problem?



> Hi there,
>    I've been having problem with the following code section:
> 
> #include<proper head>
> 
> main()
> {
>     vector<int> a_i_vec(5, 0);  
>     ....
> }

This is a known problem.  What's happening is that the compiler tries to
instantiate the two-iterator constructor because both arguments have the
same type.  That is, it thinks you asked for vector::vector(InputIter,
InputIter), not vector::vector(size_type n, const T& value).  Ideally we
should have specializations to take care of this case.

> if I change the main() code to
>     int dummy_int(0);
>     vector<int> a_i_vec(5, dummy_int);
> 
> it works. You can find the examples for the former code in
> several books for STL. It would be appreciated if somebody
> could shed a light.

a_i_vec(5U, 0) would also work.


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