std::next and std::prev are C++11 iterator utilities that return the succeeding or preceding iterator. If the provided iterator models random access, the operation will be constant, even if a custom distance is specified. Compiler Explorer link: https://lnkd.in/enJJNjxs #cpp #cplusplus #coding #programming #dailybiteofcpp
I always had an assumption that iterator don't have any information about type of iterator. That's why I always insist that container member function is better than their algorithmic counterpart , if exists. I believe this is still true (https://www.linkedin.com/pulse/algorithm-function-vs-stl-class-member-ketan-lalcheta?trackingId=urHppL21TOuDSYYnOG%2B%2F7g%3D%3D&lipi=urn%3Ali%3Apage%3Ad_flagship3_detail_base%3BLy4LDA7RTFmkoAX4se4haA%3D%3D), but looking at std::next ,giving us different Time complexity, forces me to re-think about iterator holding type or not. Thanks Šimon Tóth for sharing this.
I wonder , is there a difference over using the plus and minus operators?
PE Bytes•2K followers
2yIs not it simply pointer arithmetic for contiguous data?