What I am trying to do, is return a ForwardIterator(or even a pair of begin and end iterators), so that the uderlying implementation can be kept hidden from a client class.
I was not able find any such example.
if underlying implementation is vector, the iterator is vector::iterator.. Even if you templatize the output , this does not seem to work.
You can’t simultaneously return an object as is and expect the caller not to know its type. The typical way to “hide” the real type of any object is to hide it behind an interface.
For example, you might want to write something like this:
Then, you can return any forward sequence as:
And use it like so: