Boost logo

Boost :

From: Thorsten Ottosen (nesotto_at_[hidden])
Date: 2004-05-07 21:36:17


| > hm...empty() is O(N) for strings if implemented as end() - begin(), but
| > O(1) currently.
|
| What kind of string doesn't have random-access iterators? Or are you
| talking about C-strings which would have an O(N) end() function?

yes.

| I am leery of performance discontinuities like O(N) for end(char
| const*). Maybe it just shouldn't be provided (or something).

Pavol uses it havily in his string library. The "dangerous" thing would be not to put
computation of the end-iterator out-side the loop, eg.

for( iterator_type_of<T>::type i = begin( c ); i != end( c ); ... )
                                                                  ^^^^^^^^^^ ^
is not good. But one wouldn't do that anyway. And if one did it, what are the chances of
the argument being a char*?

br

Thorsten


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk