Boost logo

Boost :

From: David Abrahams (dave_at_[hidden])
Date: 2006-05-11 00:18:00

Larry Evans <cppljevans_at_[hidden]> writes:

> On 05/10/2006 04:10 PM, David Abrahams wrote:
>> Larry Evans <cppljevans_at_[hidden]> writes:
> [snip]
>>>OK, maybe I misunderstood. I thought that since operator* returns a
>>>value instead of a type (obviously), that two iterators would be equal
>>>only when they were the same length and each value returned by operator*
>>>was equal. Is that not the case?
>> Do you dereference normal STL iterators inside their comparison operators?
> Nope, you're right. However, the reason I mentioned operator* was to
> emphasize that the operators, whether * or == applied to values, not
> types.

Yes, in the STL they apply to values, but not in Fusion.

> The operator== applied to std::vector<I>::iterator and
> std::vector<I>::iterator would probably compare an I* with an I*
> and not use:
> is_same< std::vector<I>::iterator, std::vector<I>::iterator>::value

Yes, STL has iterators whose position can only be measured at runtime.
Fusion has iterators whose position can be measured at compile-time.
But -- not to put too fine a point on it -- so what?

> I'll admit I shouldn't have mentioned anything about length;
> however, if two stl iterator's do compare equal then the operator*
> would return the same value for the same number of operator++'s,
> wouldn't they?

Assuming the comparison was a well-defined operation in the first
place, yes. If you're comparing iterators from different sequences,
all bets are off.

Dave Abrahams
Boost Consulting

Boost list run by bdawes at, gregod at, cpdaniel at, john at