next

namespace opentl {
    template <typename It>
        requires opentl::iterator<It>
    constexpr It next(It it, opentl::ptrdiff_t n = 1) noexcept;
}

Returns a copy of the iterator advanced by n positions.

Declared in <iterator/next.hpp>.

Template Parameters

Name Description
It The iterator type.

Parameters

Name Description
it The iterator to advance.
n The number of positions to advance by, negative values backtrack.

Return Value

A copy of the iterator advanced by n positions, the original iterator is left unchanged.

Example

#include <opentl/iterator.hpp>

int main() {
    int values[] = { 1, 2, 3, 4 };
    int* it = values;

    auto next = opentl::next(it);      // points to 2
    auto last = opentl::next(it, 3);   // points to 4
}