Helpers for Generic C++ Code Iterating Over Sequences
December 12, 2020
The iterator library that is part of the C++ Standard Library provides the following helpers for writing generic code:
#include <iterator> // helpers are defined here
template<class Container>
void foo(Container& c)
{
// Generic way to obtain (constant) iterators
auto b = std::begin(c); // (1)
auto cb = std::cbegin(c); // (2)
auto e = std::end(c); //…