Because std::next intended not only for working with source pointers, but also for all iterators, therefore it is more universal.
Your assumption is also incorrect. Both approaches are likely to lead to the same build using a reasonable level of optimization. Again, C ++ is intended to simplify this optimization. In your example, the main type of the iterator is an explicit pointer, and it is pretty trivial to infer that a function call can be inlined.
EDIT:
As Matt said in his comment, iterators are more than just a fancy name and shell pattern. There are data structures (containers) that are not in a contiguous segment of memory (for example, a map or set ), they need to use more logic to determine the exact location in memory. Iterators also wrap this, they provide a level of abstraction between the algorithms and the container.
Thus, summing above points, using standard idioms helps in writing more reliable code, i.e. support for various types of containers (not caring about their memory layout), while maintaining efficiency, when possible, due to fairly smart compilers.
luk32 source share