Boost logo

Boost :

From: Jesse Jones (jejones_at_[hidden])
Date: 2000-11-17 17:49:26


>--- In boost_at_[hidden], Douglas Gregor <gregod_at_r...> wrote:
>> On Fri, 17 Nov 2000 19:40:05 -0000
>> 1) I use one "Callback" class that takes any number of parameters
>> instead of having many Callback0, Callback1, ..., CallbackN
>> classes.
>
>In theory I really like this. Unfortunately, it requires partial
>template specialization and so may hinder or prevent implementation
>on VC++, which I think is a major problem. It's definately an idea
>worth looking into, however.

Yup

>> 3) I have explicit classes (each derived from EventBase) which
>> allow callbacks to member functions, free functions or
>> functors. It appears that the William Kempf and Jesse Jones'
>> solution would use only functors (relying on another library
>> (the lambda library?) to build functors out of free/member
>> functions).

My (and I think William's version) handle free functions in the same way as
functors are handled. Member functions need a bit more. I think they should
be rolled into the core callback code, but William is so far unpersuaded.

>> This makes it tougher to include the bool
>> conversion (how do we know if a functor has a real target or
>> not?), which I consider essential.
>
>The bool conversion can be handled by inclusion of a default
>constructor that sets the "impl" pointer to null.

Yep (of course a const void* conversion would be better than bool).

>The actual functor
>is an internal detail that does not effect this in any way. I find
>it useful to leave things as they are in our implementation in order
>to not duplicate the effort of creating functors yet again. There
>are already numerous libraries available for doing this, including
>the standard library that comes with every compiler. Libraries such
>as Lambda do a much better job of this than we could possibly do with
>out duplicating a tremendous amount of effort, and with no clear
>benefit.

It's not a "tremendous amount of effort". :-) It's a bit tedious, but it
falls out very naturally from the code I posted.

  -- Jesse


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