[C++-sig] [boost.python] Interoperability with boost.bind

David Abrahams dave at boost-consulting.com
Mon Jul 4 14:24:00 CEST 2005

Markus Schöpflin <markus.schoepflin at comsoft.de> writes:

> David Abrahams wrote:
>> Markus Schöpflin <markus.schoepflin at comsoft.de> writes:
>>>Is boost.python compatible with boost.bind (see example below)? 
>> Not in that way, no.  The requirements of def() are clearly spelled
>> out in http://www.boost.org/libs/python/doc/v2/def.html#def-spec, and
>> bind_t<> specializations do not meet them ... mostly because I don't
>> have a way to deduce the signature of a bind expression.
>> However, you can do:
>>     def(
>>         "foo"
>>       , make_function(
>>             bind(foo,_1)
>>           , default_call_policies()
>>           , boost::mpl::vector<int,int>()
>>         )
>>     )
>> See http://www.boost.org/libs/python/doc/v2/make_function.html
> Thanks for the answer, Dave. IOW, if there would be a way to get the 
> signature of the bind expression, 

There is none. Consider that you can wrap function objects with
templated operator():

   struct F
       template <class T>
       T* operator()(T) const;

what is the signature of



> maybe via some support from bind itself, there would be a way to
> make to original example work, right?

Right.  But there is no way to do it.

Dave Abrahams
Boost Consulting

More information about the Cplusplus-sig mailing list