Consider the following simplified example and desired output:
class A
{
class combined_iterator
{
????
}
typedef ??? t_combined_it;
I think your "naive" approach should work, with the following change: instead of comparing the iterator to the end()
of every container, keep a pointer to the current container and compare the iterator only the the current container's end()
. When the end has been reached, move on to the next container. That way, you'll never compare the iterator to another container than the one it points to. This will also easily generalize to an arbitrarily-sized collection of collections.