I have created a C++ implementation of a collection type.
I would like to add iteration support so that developers may use the “for each” statement on it.
How can I do that?
I have created a C++ implementation of a collection type. I would like to
Share
The standard idiom is : expose types
iteratorandconst_iteratorand provide minimum two functions namely,begin()andend()as:Once you implement these, your collection can be used in
std::for_each, and in a lot other algorithmic functions which are defined in<algorithm>.