[python][lambda] thin wrapper functions using boost.lambda
Hi, I would like to use lambda functions to define thin wrapper functions in boost::python, like struct A{ void meth1(); }; [...] python::class_<A>("A").def("meth1",lambda::bind(&A::meth1,lambda::_1)); and I am getting "error: no matching function for call to 'get_signature [...]' " from the compiler. Reading boost::lambda documentation (http://www.boost.org/doc/libs/1_39_0/doc/html/lambda/using_library.html#lambda.parameter_and_return_types): """The basic rule is that a lambda function can be called with arguments of any types, as long as the lambda expression with substitutions performed is a valid C++ expression.""" Is there a way to enforce parameter types, so that boost::python can get the signature? Or, more generally, is it somehow possible to use such in-place functions to create the thin wrappers? Many thanks, Vaclav
I should have been clearer why I need that: for properties (for class methods, they can be wrapped directly using just &A::meth1). So an example like this would be more appropriate: struct A{ int num1; }; [...] python::class_<A>("A").add_property("num1",lambda::bind(&A::num1,_1)); which fails again. How can I access the num1, besides creating separate function? Thanks, Vaclav
Vaclav Smilauer wrote:
I should have been clearer why I need that: for properties (for class methods, they can be wrapped directly using just &A::meth1). So an example like this would be more appropriate:
struct A{ int num1; }; [...] python::class_<A>("A").add_property("num1",lambda::bind(&A::num1,_1));
which fails again. How can I access the num1, besides creating separate function?
http://www.boost.org/doc/libs/1_39_0/libs/python/doc/tutorial/doc/html/pytho...
http://www.boost.org/doc/libs/1_39_0/libs/python/doc/tutorial/doc/html/pytho... Thanks and my apologies for the stupid question. I'e been using .def and .add_property all the time, as it was all I needed and forgot about those completely :-|
participants (3)
-
Nat Goodspeed
-
Vaclav Smilauer
-
Václav Šmilauer