4 ms·
The standard's requirements for the standard library types don't imply any corresponding requirement for types you define yourself. If you want to write a conta
by plorkyeran 5y ago
The standard's requirements for the standard library types don't imply any corresponding requirement for types you define yourself. If you want to write a container which can't reasonably do O(1) size() then you just don't do O(1) size(). If such a container was added to the standard library, the standard library's Container requirements will be adjusted to permit that.
- chakkepolja 5y agoExactly, 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.
- tialaramex 5y agoWait, 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.