Boost logo

Boost :

From: David Abrahams (dave_at_[hidden])
Date: 2004-03-11 15:14:24


Brian McNamara <lorgon_at_[hidden]> writes:

> On Thu, Mar 11, 2004 at 05:35:38PM +0200, Peter Dimov wrote:
>> Yes, I understand the Long-Term Goal (if not its utmost importance), but
>> your approach doesn't scale to other function<>-like entites.
>>
>> void f();
>> my_function<void()> g(f);
>> your_function<void()> h(g);
>>
>> g == h; //???
>> g.contains(h); // false
>> h.contains(g); // true
>>
>> It's limited to the one and only function<> (and you can't even ask a
>> function<> whether it contains another function<>, right?)
>
> I am also curious about how cases like
>
> void f(int,int,int);
> function<void(int,int)> tmp1 = bind(&f,5,_1,_2);
> function<void(int,int)> tmp2 = bind(&f,_1,_2,7);
> bind(tmp1,_1,7) == bind(tmp2,5,_1) // ?
>
> (ought to) work. (If my intent isn't clear above, I am trying to bind
> the first and third arguments of f() in two different ways. Presumably
> the LHS and RHS of the operator== on the last line have different
> types, despite the fact that they "are the same function", for some
> definition of sameness.)

Just to throw more darts at the idea, building the composite function
object could be an expensive way to arrive at an immediate bool result
if copying the function objects was a nontrivial operation.

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

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