#include #include "boost/python/class_builder.hpp" using namespace boost::python; struct Expression { Expression() {} }; struct Term { Term() {} Term(const Expression&) {} }; void f(const Term& t) {} struct A { A(const Term&) {} }; BOOST_PYTHON_BEGIN_CONVERSION_NAMESPACE PyObject* to_python(const Expression& e) { return to_python(Term(e)); } BOOST_PYTHON_END_CONVERSION_NAMESPACE BOOST_PYTHON_MODULE_INIT(convert) { try { module_builder convert("convert"); class_builder Term_(convert, "Term"); Term_.def(constructor<>()); Term_.def(constructor()); class_builder Expression_(convert, "Expression"); Expression_.def(constructor<>()); convert.def(f , "f"); class_builder A_(convert, "A"); A_.def(constructor()); } catch(...) { } }