Custom iterator for a class based on two sets
- by Dan Hook
I have a class that contains two sets. They both contain the same key type but have different compare operations.
I would like to provide an iterator for the class that iterates through the elements of both sets. I want to start with one set, then when I increment an iterator pointing to the last element of the first set, I want to go to the first element of the second set. How do I do this? I would like to preserve the bidirectional iterator semantics of std::set, but if it turns out that implementing a forward iterator is much easier, so be it.
I'm willing to use the Boost Iterator library if that would help.