Getting ready
In this recipe, we will use as an example, the dummy_array class and its iterators that we implemented in the previous recipe, Writing your own random access iterator. You should read that recipe before continuing with this one.
Non-member begin()/end() functions and the other variants, as well as non-member data(), size() and empty() are available in the std namespace in the <iterator> header, which is implicitly included with any of the following headers: <array>, <deque>, <forward_list>, <list>, <map>, <regex>, <set>, <string>, <unordered_map>, <unordered_set>, and <vector>.
In this recipe, we will refer to the std::begin()/std::end() functions, but everything discussed also applies to the other functions: std::cbegin()
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access