help-gplusplus
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Help with vector iterator


From: Guy Harrison
Subject: Re: Help with vector iterator
Date: Fri, 07 Jan 2005 23:00:10 GMT
User-agent: KNode/0.7.7

Garrett Kajmowicz wrote:

> I'm implementing the C++ standard library + stl for embedded systems
> (ucxx.uclibc.org).  I have an implementation of std::vector which works
> quite well up until you try and do vector<int>.  Any other data type is
> find.
> 
> There are many problems which I have encountered, but this is the most
> obvious (and I am hoping will lead me to the rest of the solution).
> 
> There are two insert functions I must provide:
> 
> void insert(iterator position, size_type n, const T& x );
> template <class InputIterator> void insert(iterator position,
> InputIterator first, InputIterator last)
> 
> For some reason, when I am using a data type of int, it will treat an
> integer as an iterator which really screws things up.  Try dereferencing
> and integer some time and enjoy the compiler errors.  In short, it always
> calls the second function, even when I want it to call the first.
> 
> What should I do to avoid this horrible mess?

I'm no expert on STL for sure. Peer into some sources. You'll find (as I
did) that iterators are distinct types. At first sight such "dross" as...

struct input_iterator_tag {}

...has no meaning but when you follow it for a bit it starts to make sense.
For g++ look in */bits/stl_iterator* (eg stl_iterator_base_types.h).



reply via email to

[Prev in Thread] Current Thread [Next in Thread]