Boost logo

Boost :

Subject: Re: [boost] [Review:Algorithms] Order of args to clamp
From: Dave Abrahams (dave_at_[hidden])
Date: 2011-09-25 13:48:51


on Sun Sep 25 2011, Steven Watanabe <watanabesj-AT-gmail.com> wrote:

>> Here's an exercise:
>>
>> 1. Write down the documentation for both the multi-type and single-type
>> "clamp" algorithms. Describe both the concept requirements on the
>> algorithm parameters, and the result of each algorithm (without
>> making reference to its implementation).
>>
>
> It seems fairly straightforward. All that's necessary
> is to require that comparing objects of different types
> is equivalent to converting to the same type and then
> comparing and define the result to be the same as though
> we converted first and called the single type version.

So, do the exercise. And, BTW, which of the types involved is "the same
type" in this case?

>> 2. Demonstrate that the multi-type algorithm does what the single type
>> algorithm does when passed only a single argument type.
>>
>> 3. Imagine yourself wanting to clamp an int. Compare the documentation
>> and reasoning you'd have to go through to satisfy yourself that the
>> algorithm does what you want in each case.

It's easy to wave one's hands about how straightforward it seems when
you aren't looking at the actual realization. Show me how it actually
plays out and then we'll see if the flexibility is worth the
complication.

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