I don't use sets too often, and to tell you for sure I'd have to do a 1h+ research in the standard. However, that wouldn't be too helpful, since most implementations aren't 100% standard compliant (otherwise std::set::const_iterator would be equal to std::set::iterator, I think).
I'd try to wrap the iterators into a common object like:
1 2 3 4 5 6 7 8
|
struct iter_wrap
{
iter_1 i1_;
iter_2 i2_;
iter_wrap(iter_1 i1) {i2_=my_set.end(); i1_ = i1;}
iter_wrap(iter_2 i2) {i1_=my_set.end(); i2_ = i2;}
}
vector<iter_wrap> vi;
|
If that's feasable for you, it seems to be the best way (stl code and polymorphism don't mix too well... all classes are concrete, so no virtual destructors, so think twike before inheriting from them etc...)
By the way, do you know a source, were i can find more information about the internal structure of iterators / stl containers? |
(Un?)fortunately, the standard doesn't say anything about how things have to work internally, just the interface is specified (where interface means more than just declarations. E.g., the concept "
Assignable" means for type T: T has a copy constructor, a copy assignment operator, and copies are equivalent something like
1 2 3 4 5 6
|
T t;
T u(t);
T v;
v=u;
assert(t==u);
assert(t==v);
|
(not quite:
Assignable doesn't imply
Equality Comparable, but you get the spirit)
As a reference about the concepts, models and requirements in the STL, I use "Generic Programming and the STL" by Austern.