Boost logo

Boost :

From: Alex Besogonov (cyberax_at_[hidden])
Date: 2006-01-15 10:38:52


Peter Dimov wrote:
> Most of the time is probably due to function<>'s dynamic dispatch mechanism;
> I'm not sure how FastDelegate can help.
I've tried to hack it into function<> myself but I've failed :)

I'm thinking of something like:
======================
       union function_buffer
       {
        //FastDelegate
        FastDelegateData delegate_data;

         // For pointers to function objects
         void* obj_ptr;

         // For pointers to std::type_info objects
         // (get_functor_type_tag, check_functor_type_tag).
         const void* const_obj_ptr;

         // For function pointers of all kinds
         mutable void (*func_ptr)();

         // For bound member pointers
         struct bound_memfunc_ptr_t {
           void (X::*memfunc_ptr)(int);
           void* obj_ptr;
         } bound_memfunc_ptr;

         // To relax aliasing constraints
         mutable char data;
       };
======================
'delegate_data' should be used if we're creating a delegate (i.e.
pointer to method with bound 'this' pointer). It's called a 'closure' in
Borland-speak.

It will complicate code a lot though, because simple
'mpl::bool_<(function_allows_small_object_optimization<functor_type>::value)>()'
won't be enough.

> You could also try a test using ct_mem_fn< void (X::*)(), &X::f > where
> ct_mem_fn is
This is fine, but we're losing generic interface of function<> :(

-- 
With respect,
             Alex Besogonov (cyberax_at_[hidden])

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