vendredi 20 novembre 2020

Are the end iterators always in the rhs of the comparison?

From what I have found in my testing range-based standard algorithms and containers always do the following comparison it!=c.end() aka the end iterator is on the right of the != operator and I want to know if there's an standard or some warranty that the following will not appear on the STL implementation c.end()!=it

I'm curious because I'm building an iterators library and my != operator looks something like this

bool operator!=(const Iterator& lhs, const Iterator& rhs)
{
    return lhs._validate();
}

Which is valid as long as the rhs is always the end iterator

Aucun commentaire:

Enregistrer un commentaire