Angew made a comment that a vector
using a raw pointer as it's iterator type was fine. That kinda threw me for a loop.
I started researching it and found that the requirement for vector
iterators was only that they are "Random Access Iterators" for which it is explicitly stated that pointers qualify:
A pointer to an element of an array satisfies all requirements
Is the only reason that compilers even provide iterators to vector
for debugging purposes, or is there actually a requirement I missed on vector
?
template <class Container> void doStuff(const Container& c) { for (Container::iterator i = c.begin(); i != c.end(); ++i) { ... } }
A template like this doesn't care what type of container you use as long as it providesiterator
,begin
andend
. – Calashstd::vector<T>::iterator
. Pointers do not havestd
as an associated namespace. The Standard does not require iterators to havestd
as an associated namespace, though. – Swainsonstd::vector<T>::iterators
with unqualifiedswap(it1, it2)
? – Swainson