Only a few algorithms in the standard library offer counted variants that operate using a begin iterator and the number of elements.
C++20 introduced the std::counted_iterator adapter that can turn any range version of an algorithm into a counted variant.
Click to open in Compiler Explorer.
Leave a comment