[C++-sig] [python] Function objects in place of member functions

Ravi lists_ravi at lavabit.com
Mon Oct 12 02:32:59 CEST 2009


On Sunday 11 October 2009 19:44:29 troy d. straszheim wrote:
> > Why is the overloaded get_signature not picked up when it is declared
> > after  the inclusion of the headers?
> 
> I'm not sure why it isn't picked up.

Does that mean that you can reproduce the problem I pointed out?

> I've been working in this area, 
> replacing most of detail/caller.hpp and detail/invoke.hpp with 
> boost.fusion, seen here:
> 
> http://gitorious.org/~straszheim/boost/straszheim/blobs/python/boost/python
> /detail/caller.hpp
> 
> In the process, I overhauled get_signature to use boost::function_types, 
> and to be a metafunction, not a function:
> 
> http://gitorious.org/~straszheim/boost/straszheim/blobs/python/boost/python
> /signature.hpp

IMHO, this is the right way to do it. This avoids relying on the compiler to 
optimize out all the ugly tag-dispatching. Of course, Dave A & Ralf WGK did 
not have function types when they wrote this originally.

[snip]

>    boost::function<int(X*, int)> bf0(fobj);

Why do you need to use boost::function here? Shouldn't the type be deduced 
automatically?

> I'm fairly new to the internals of boost.python, and only just now got 
> this working...  Do you see problems with this, specifically the 
> conversion of get_signature from function to metafunction?

I don't see any problems with the conversion of get_signature to a 
metafunction. Do compile times get any longer?

Regards,
Ravi



More information about the Cplusplus-sig mailing list