Aleksey Gurtovoy
Writing an algorithm for _bidirectional_ iterators and making sure that it gets selected for random-access ones as well is somewhat more tricky:
template< typename Iterator > struct algorithm : if_c< iterator_category<Iterator>::type::value >= bidirectional_iterator_tag::value , bidirectional_algorithm<Iterator> , forward_algorithm<Iterator> > { };
but try to write this up assuming that _there is_ an implicit conversion between 'random_access_iterator_tag' and 'bidirectional_iterator_tag', and you'll see that you'll end up with something at least as complex as the above.
If there was a _form_ relationship among MPL iterator tags just like
the _inheritance_ relationship among the STL ones, it would be easier
to do this with partial specialization. E.g.,
typedef tag<> forward_iterator_tag;
typedef tag
{
...
};
doesn't really communicate well. Maybe some built-in SFINAE
facilities would help?
template