So, I just noticed that, for some reason, std::const_reverse_iterator is implicitly converted to std::reverse_iterator but std::const_iterator is not implicitly converted to std::iterator in my example. I am using cbegin and crbegin to retrieve const iterators from my vector:
#include <vector>
int main()
{
    typedef std::vector< int > Vector_t;
    Vector_t Vector;
    Vector_t::iterator          Iterator1  = Vector.cbegin();   // error
    Vector_t::reverse_iterator  Iterator2  = Vector.crbegin();  // ok
}
Why is this? Shouldn't the rules be the same for forward- and reverse iterators?
Aucun commentaire:
Enregistrer un commentaire