I am trying to use lambdas C ++ 11 as an access function in boost::python add_property , something like the following (in this example, lambda is not strictly needed, but will be needed for more complex things happening inside lambda, for example, checking):
However compiling with clang ++ (version 3.2) and -std=c++11 (the result is the same with g ++ 4.7), I get this error:
/usr/include/boost/python/class.hpp:442:66: error: no matching function for call to 'get_signature' return python::make_function(f, default_call_policies(), detail::get_signature(f, (T*)0)); ^~~~~~~~~~~~~~~~~~~~~ /usr/include/boost/python/class.hpp:422:22: note: in instantiation of function template specialization 'boost::python::class_<A, boost::python::detail::not_specified, boost::python::detail::not_specified, boost::python::detail::not_specified>::make_fn_impl<A, <lambda at boost_python_lambda.cpp:12:21> >' requested here return this->make_fn_impl( ^ /usr/include/boost/python/class.hpp:309:40: note: in instantiation of function template specialization 'boost::python::class_<A, boost::python::detail::not_specified, boost::python::detail::not_specified, boost::python::detail::not_specified>::make_getter<<lambda at boost_python_lambda.cpp:12:21> >' requested here base::add_property(name, this->make_getter(fget), docstr); ^ boost_python_lambda.cpp:12:4: note: in instantiation of function template specialization 'boost::python::class_<A, boost::python::detail::not_specified, boost::python::detail::not_specified, boost::python::detail::not_specified>::add_property<<lambda at boost_python_lambda.cpp:12:21> >' requested here .add_property("a",[](const A& a){return aa;}) ^
I tried wrapping the lambda in std::function<int(const A&)>(...) , but this did not help to output the argument. Any idea?
c ++ lambda c ++ 11 boost-python
eudoxos
source share