How do I expose the following 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 raises an exception in Python (SystemError: initialization of libdistributions raised unreported exception
). If I remove one of the overloads from the bp::class_
, then everything works fine. I know that Boost.Python can automatically deal with overloaded constructors, so I was wondering if there was something like that for static methods.
bp::class_<C>("C")
.def("F", (void (C::*)(int))&C::F) // Note missing staticmethod call!
.def("F", (void (C::*)(double))&C::F).staticmethod("F")
;
I think here you can find the solution to your problem:
http://www.boost.org/doc/libs/1_48_0/libs/python/doc/tutorial/doc/html/python/functions.html#python.overloading
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With