I'm trying to implement C++'s reverse function as an exercise. The exercise instructions (from Caltech's advanced C++ course) hint that you should use the `distance` function, which counts the number of items between two iterators. Using this hint, I wrote the below function, which appears to work:

```
template <typename BidirectionalIterator>
void my_reverse(BidirectionalIterator first, BidirectionalIterator last) {
    last--; // input "last" is one past the end
    while( first != last && distance(first, last) > 1 ){
        std::swap(*first, *last);
        first++;
        last--;
    }
    return;
}

```

But I have a problem with this approach: if I'm not mistaken, calling `distance` at each step makes this an O(n^2) algorithm.
So I replaced the while condition with the following:

```
    while( first < last ){

```

This also appears to work. But it makes me a little nervous, because the documentation on BidirectionalIterators doesn't guarantee that the iterators can be ordered like this. Can I trust that this ordering will always work as intended, and that `v.end()` will always be greater than `v.begin()` for an STL container object `v`?

(My concern comes from thinking like a Haskell programmer that BidirectionalIterators are guaranteed to have properties of Eq, so to speak, but not Ord.)