Re:In C++, is empty() faster than comparing the size with zero?
by chakkepolja on Thursday October 28, 2021 @02:43PM
(#29029808)
Exactly, most STL algorithms, for example, can be applied using iterators as well. But anyway if GP has specific requirements iterator invalidation might be a problem too, they wouldn't probably want to constrain their interface to that of STL containers.
[ Parent
| on HN ]
Re:In C++, is empty() faster than comparing the size with zero?
by tialaramex on Thursday October 28, 2021 @04:42PM
(#29031671)
Wait, isn't the point of the STL algorithms that they use iterators?
For sure the iterator over a vector may be very cheap to use, but it is still an iterator, even if you tacitly know it's just pointer arithmetic under the hood.