I am trying to expose the C++ class with name aliasing to python using boost python.
struct Foo
{
void hi() const { std::cout << "hi" << std::endl; }
};
BOOST_PYTHON_MODULE(Example)
{
typedef Foo Bar;
class_<Foo>("Foo")
.def("hi", &Foo::hi)
;
class_<Bar>("Bar")
.def("hi", &Bar::hi)
;
}
The code works as expected except the annoying RuntimeWarning.
RuntimeWarning: to-Python converter for Foo already registered; second conversion method ignore
Adding Bar = Foo in python also works. But I need to keep the definitions in the same module. Is there a better way to achieve this?