address issue with virtual function dispatch (fixes #159)
diff --git a/example/issues.cpp b/example/issues.cpp
index 1a4fc31..c9f9e8b 100644
--- a/example/issues.cpp
+++ b/example/issues.cpp
@@ -9,7 +9,25 @@
#include "example.h"
+struct Base {
+ virtual void dispatch(void) const = 0;
+};
+struct DispatchIssue : Base {
+ virtual void dispatch(void) const {
+ PYBIND11_OVERLOAD_PURE(void, Base, dispatch);
+ }
+};
+
+void dispatch_issue_go(const Base * b) { b->dispatch(); }
+
+PYBIND11_PLUGIN(mytest)
+{
+ pybind11::module m("mytest", "A test");
+
+
+ return m.ptr();
+}
void init_issues(py::module &m) {
py::module m2 = m.def_submodule("issues");
@@ -18,4 +36,12 @@
// #150: char bindings broken
m2.def("print_char", [](char c) { std::cout << c << std::endl; });
+
+ // #159: virtual function dispatch has problems with similar-named functions
+ pybind11::class_<DispatchIssue> base(m2, "DispatchIssue");
+ base.alias<Base>()
+ .def(pybind11::init<>())
+ .def("dispatch", &Base::dispatch);
+
+ m2.def("dispatch_issue_go", &dispatch_issue_go);
}