Boost logo

Boost :

Subject: Re: [boost] Boost.Algorithm design question
From: Dave Abrahams (dave_at_[hidden])
Date: 2011-10-06 21:01:56

on Thu Oct 06 2011, "Peter Dimov" <> wrote:

> Dave Abrahams wrote:
>> > 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...

It encodes the requirement that the two things we're comparing have the
same type.

>> 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.

Only if we're being standards-pedantic. If we're being mathematical and
using commonly accepted definitions of terms, it is perfectly

> 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.

I claim that "finds the first element in [first, last) that equals
value" is a better way to say it.

Dave Abrahams
BoostPro Computing

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