
I have two multi_index_containers that are identical except for the ordering of the iterators. For example: struct Foo { long x, y; }; typedef boost::multi_index_container<Foo, indexed_by<ordered_non_unique<composite_key<Foo, member<Foo, long, &Foo::x>, member<Foo, long, &Foo::y> > > > > FooAscending; typedef boost::multi_index_container<Foo, indexed_by<ordered_non_unique<composite_key<Foo, member<Foo, long, &Foo::x>, member<Foo, long, &Foo::y> >, composite_key_compare<std::greater<long>, std::greater<long> > > > > FooDescending; The containers are indexed on composite keys of x and y - one in ascending order of y, the other in descending order. I have code that operates on iterators over these containers. Conveniently, the operation is identical, save for the ordering, so I can reuse the interesting code that works on these iterators. However, I am finding that the iterator types for the two containers are identical. Yet if I just define my overload for one of the iterators, everything works as expected. So my question is, is there a way to specify a generic iterator over a multi_index_container such that code on iterators can be reused in this way? It seems from the symbols gcc spits out that the iterator type depends only on the type held and the number of indices in the container (i.e. a container with a unique key on just Foo::x would also have its iterator type collide with FooAscending::iterator and FooDescending::iterator). Thanks, Jonathan