
13 May
2009
13 May
'09
3:34 p.m.
Peter Dimov skrev:
Attached is proof-of-concept code for a sentinel iterator adapter. It turns a pointer to sentinel terminated sequence, such as a C-style string, into a forward iterator with a conforming end iterator.
This is more efficient than doing a separate sequence traversal just to find the end.
No, it is not. :-)
In Boost.StringAlgo the end iterator is usually computed by a call to strlen(). I suspect for algorithms that do not need a. random access iterators b. to discover the whole range before terminating then a sentinel range could be more efficient. Of course, a random access range might be subject to other optimizations that are lost when the iterator cetagory is made more general. -Thorsten