|
Boost : |
Subject: Re: [boost] Boost.Algorithm design question
From: Dave Abrahams (dave_at_[hidden])
Date: 2011-10-07 15:11:27
on Fri Oct 07 2011, "Peter Dimov" <pdimov-AT-pdimov.com> wrote:
> 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.
Well, if you phrase it that way, it's a little different. The original
description only had the "otherwise" clause, right?
The "replacement" is still simpler, because you wouldn't actually write
the "otherwise ..." clause; you just say it requires EqualityComparable.
-- Dave Abrahams BoostPro Computing http://www.boostpro.com
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk