Boost logo

Boost :

From: Jesse Jones (jejones_at_[hidden])
Date: 2000-10-17 16:32:40


>> Yeah, this is good. The same applies to arguments. For example, if you
>> have
>> a callback that's defined to have a void return type and an int argument
>> it
>> should be possible to attach a member function that takes a long.
>I'm not sure I'd want this.

It'd hard to see how this would cause problems and it's a very natural
operation. The only argument conversions allowed are the normal implicit
conversions, eg int -> long, const char* -> std::string, etc.

Essentially you have a functor like this:

template <typename F, typename A>
class Callback {
public:
   void operator()(A a) {f(a);}
private:
   F f;
};

As long as A is convertible to whatever F expects you're OK.

>> >with the function adapters, binder library and some extra relaxN(...)
>> >template functions
>> >(allowing to except more arguments than actually used) almost everything
>> >can be turned
>> >into a callback...
>>
>> I've having some trouble parsing this bit.
>>
>My guess is that he's using the binder from Lambda/BL to hold the function
>pointers, extra arguments etc. I never thought about using it this way but
>it looks promising. There is some more work on Lambda being done for holding
>arbitrary lambda functions and this would help the callback problem. LL does
>the member template stuff very well. (IMO)

It's an interesting approach, but I'm a bit concerned about layering
something as fundamentally simple as callback objects onto the complex and
rather scary lambda library...

  -- Jesse


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