Boost logo

Boost-Build :

From: David Abrahams (dave_at_[hidden])
Date: 2004-02-29 16:19:10


"Eric Niebler" <eric_at_[hidden]> writes:

> Eric Niebler wrote:
>
>> David Abrahams wrote:
>>
>>
>>>Urrrh, your "std_min" function makes an unqualified call to min,
>>>right? How can you know whether the invoked function is going to
>>>return a value or a reference?
>>>
>>
>>
>> I see your point, but is this a corner case we really want to handle? If
>> users are overloading min and max, shouldn't they be using
>> std-compatible signatures? (I'm sincerely asking, these are not
>> rhetorical questions.)
>>
>
> Put another way, how do we know min(foo,foo) doesn't return a bar?
> There's a limit to how far we can take this.

Yes, but you haven't hit it yet. You can also tell whether
min(foo,bar) returns a foo or a bar or something else.

If you consider a generic algorithm using unqualified calls to min,
it almost certainly places a requirement something like:

min(x, y) is convertible to T

and not

min(x,y) is an lvalue of type X

on its clients.

-- 
Dave Abrahams
Boost Consulting
www.boost-consulting.com
 

Boost-Build list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk