Boost logo

Boost :

Subject: Re: [boost] Boost.Algorithm design question
From: Peter Dimov (pdimov_at_[hidden])
Date: 2011-10-07 04:34:28


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

I know, and I question this claim. Why is it better, when it says the exact
same thing, while needing to impose unnecessary requirements to arrive at
it?

The current specification (ignoring the conversion issue for now, as it's
separate) says:

- when T is EqualityComparable, returns the first element that equals value;
- otherwise, returns the first element *i for which *i == value.

Your preferred replacement says:

- when T is EqualityComparable, returns the first element that equals value;
- otherwise, the behavior is undefined.

Do tell me why it's better.


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