Boost logo

Boost :

Subject: Re: [boost] Boost.Algorithm design question
From: Peter Dimov (pdimov_at_[hidden])
Date: 2011-10-06 19:13:36


Dave Abrahams wrote:

> > For the non-predicate version it just says "Returns: The first
> > iterator i in the range [first,last) for which *i==value holds"
> > (n3242).
>
> Exactly, a pile of syntax.

What specifically is wrong with it?

> > none_of_equal could be written in the same style. But you seem to
> > want something different than that; I guess that you want to add a
> > requirement on the type of the value, right?
>
> No, I want to avoid a requirement by encoding it into the function
> signature.

How would you do that? The function signature can't encode the requirement
that *i == value should work, or...

> You're missing that == should *mean* something.

... mean something, or...

> You're not even requiring it to be symmetric.

... that it's equivalent to value == *i. You still need to add these
requirements. Sure, you can call them "value_type shall be
EqualityComparable" and even then, you'll have to spell "*i == value" when
describing the semantics, either directly or by saying something like "finds
the first *i that equals value", which, if we're being really pedantic,
doesn't really specify anything, because "x equals y" is not defined
anywhere.

Bottom line, you'll add a conversion and a bunch of unnecessary requirements
and end up with the exact same specification as before, namely, returns the
first i for which *i == value.


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