iterator is the generic word for something that can iterate a collection of objects.
On the other hand, I'm not sure that there is a commonly accepted word in C++ for the collection itself, in particular when the object provides begin
and end
methods.
Question: in C++, is there a commonly accepted word for an object that can be iterated through begin
and end
methods ?
The term iterable sounds quite reasonable for this (as a matter of fact, the tag exists on SO). I just wonder if it can be officially used as an answer to the question.
C++20 calls this a "range". As noted in the comments, the definition of a range is slightly more broad than what you suggest, to include e.g. plain arrays that don't have .begin()
and .end()
members. You're expected to use std::ranges::begin(...)
and std::ranges::end(...)
instead of the member functions to get those iterators.
C++20 added ways to check if a type conforms to those requirements at compile-time: std::ranges::range
and others.