On Monday 12 October 2009 08:47:22 troy d. straszheim wrote:
> >>    boost::function<int(X*, int)> bf0(fobj);
> >
> > 
> > Why do you need to use boost::function here? Shouldn't the type be
> > deduced  automatically?
> > 
> 
> Note that the .def() of the various boost::function objects work without 
> requiring the user to specialize get_signature, (since this modified 
> get_signature metafunction knows about boost::function objects).

[snip]

> I think interoperability with boost::function is a Good Thing, but in 
> the example above (and the previous), all it does is give def() a way to 
> tell what the signature of the function object is at compile time, and 
> it does so at a runtime cost.

At least for my case, that extra virtual function call is a killer.

> A specialization of get_signature works, 
> but strikes me as kinda ugly (it should at least be moved out of 
> 'detail' if it is a user customization point).  How about something like
> 
>    class_<T>("T")
>      .def("f1", f1, sig<void(T*, double)>)
>      .def<void(T*, double)>("fi", f1)

I'd rather have something along the lines of 
      .def< mpl::vector<void,T*,double> >("f1",f1)
by using function_types to compose the currect function signature. 
Alternatively, one could have the sig<> template above be a def_visitor and 
take the appropriate template arguments without the need to modify class_::def 
at all.

> >> 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?
> 
> I haven't checked this yet.  I have other concerns re typechecking and 
> automatic conversions...

Care to elaborate?

Regards,
Ravi


_______________________________________________
Cplusplus-sig mailing list
Cplusplus-sig@python.org
http://mail.python.org/mailman/listinfo/cplusplus-sig

Reply via email to