I want to pass a callable object from Python to C++ and then call it from C++ with arguments for which I have registered base_. Example:
namespace bpy = boost::python;
bpy::class_<X, X*, boost::noncopyable>("X", bpy::no_init);
bpy::def("f", +[](bpy::object fn) {
fn(new X());
});
Then from python:
from example import f
def fn(x):
print "x.g() =", x.g()
f(fn)
Throws:
TypeError: No to_python (by-value) converter found for C++ type: X
I have no issue with callable taking other types of arguments, e.g., int, float or some other types I have registered, but this one is failing and I don't understand why: why is a by-value conversion required when I'm passing a X* and I've specified that the held type for X is X*.
Any suggestion on how to fix this?
Full example on Coliru: http://coliru.stacked-crooked.com/a/b3492d2e846d705c