![]() | Ned Batchelder : Blog | Code | Text | Site STL iterators can be char* » Home : Blog : December 2002 |
STL iterators can be char*Tuesday 10 December 2002 Here's a handy fact about the C++ Standard Template Library that I didn't know: a char* (or any other pointer) is a valid iterator. This is because it is all templates, and iterators are anything that supports increment (++), and indirection (*); and whose elements support things like equality (==) and assignment (=). For example, to search one chunk of memory for another chunk: #include <algorithm> Just be careful: if the data isn't found, search returns pBufEnd, not NULL! Found this in the C++ forum at Experts Exchange. | |
Comments
Add a comment: