itertools::enumerate

#include <itertools.hpp>

Synopsis

template<typename R>
enumerated<R> enumerate (R && rg)

Template parameters

  • R Range type.

Parameters

  • rg Range to enumerate.

Returns

A itertools::enumerated range.

Example

#include <itertools/itertools.hpp>
#include <vector>
#include <iostream>

int main() {

  std::vector<int> v{10, 11, 12, 13, 14};

  for (auto [n, x] : itertools::enumerate(v)) std::cout << n << "  " << x << std::endl;
}

Output

0  10
1  11
2  12
3  13
4  14