Example of bug in functions returning bool overriden in python
diff --git a/example/example12.cpp b/example/example12.cpp
index 57a0765..7bba2c8 100644
--- a/example/example12.cpp
+++ b/example/example12.cpp
@@ -27,6 +27,7 @@
return state + value;
}
+ virtual bool run_bool() = 0;
virtual void pure_virtual() = 0;
private:
int state;
@@ -47,6 +48,14 @@
);
}
+ virtual bool run_bool() {
+ PYBIND11_OVERLOAD_PURE(
+ bool,
+ Example12,
+ run_bool
+ );
+ }
+
virtual void pure_virtual() {
PYBIND11_OVERLOAD_PURE(
void, /* Return type */
@@ -61,6 +70,10 @@
return ex->run(value);
}
+bool runExample12Bool(Example12* ex) {
+ return ex->run_bool();
+}
+
void runExample12Virtual(Example12 *ex) {
ex->pure_virtual();
}
@@ -75,8 +88,10 @@
.def(py::init<int>())
/* Reference original class in function definitions */
.def("run", &Example12::run)
+ .def("run_bool", &Example12::run_bool)
.def("pure_virtual", &Example12::pure_virtual);
m.def("runExample12", &runExample12);
+ m.def("runExample12Bool", &runExample12Bool);
m.def("runExample12Virtual", &runExample12Virtual);
}