Boost logo

Boost :

Subject: Re: [boost] Boost.Algorithm design question
From: Stephan T. Lavavej (stl_at_[hidden])
Date: 2011-10-06 19:00:28


[Phil Endecott]
> But in any case, it's not hard to write; just require that T is a type
> for which *i==value is valid.
>
> What am I missing?

[Dave Abrahams]
> You're missing that == should *mean* something.

Why should the algorithm assume any more meaning than it has to?

For example, std::equal() does not require symmetry. This is just fine for people comparing a range of T to a range of T, where T == T is symmetric, and makes people comparing a range of X to a range of Y, where X == Y is provided and Y == X has not even been implemented (and X can't be converted to/from Y), super happy.

> You're not even requiring it to be symmetric.
> Why is it right to test *i==value instead of value==*i?

The algorithm takes (first, last, value), putting the range on the left and the value on the right.

STL


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk