Daily bit(e) of C++

Share this post

Daily bit(e) of C++ | std::advance, std::distance

simontoth.substack.com

Daily bit(e) of C++ | std::advance, std::distance

Daily bit(e) of C++ #256, Generic functions for advancing iterators and measuring distance between iterators: std::advance, std::distance.

Šimon Tóth
Sep 14, 2023
2
Share this post

Daily bit(e) of C++ | std::advance, std::distance

simontoth.substack.com
Share

When implementing generic code that should operate on top of ranges, the std::advance and std::distance utilities can help.

Both utilities provide constant complexity for random access ranges and fallback to linear operations.

Click to open in Compiler Explorer.

Leave a comment

Thanks for reading Daily bit(e) of C++! Subscribe for free to receive new posts and support my work.

2
Share this post

Daily bit(e) of C++ | std::advance, std::distance

simontoth.substack.com
Share
Comments
Top
New
Community

No posts

Ready for more?

© 2023 Šimon Tóth
Privacy ∙ Terms ∙ Collection notice
Start WritingGet the app
Substack is the home for great writing