Overloading the static Boost.Python method

How to open the next class using Boost.Python?

class C { public: static void F(int) {} static void F(double) {} }; 

I tried something like this:

 bp::class_<C>("C") .def("F", (void (C::*)(int))&C::F).staticmethod("F") .def("F", (void (C::*)(double))&C::F).staticmethod("F") ; 

But it throws an exception in Python ( SystemError: initialization of libdistributions raised unreported exception ). If I remove one of the overloads from bp::class_ , then everything will be fine. I know that Boost.Python can automatically handle overloaded constructors, so I was wondering if there was anything like this for static methods.


Answer

 bp::class_<C>("C") .def("F", (void (C::*)(int))&C::F) // Note missing staticmethod call! .def("F", (void (C::*)(double))&C::F).staticmethod("F") ; 
+4
source share

Source: https://habr.com/ru/post/1389107/


All Articles