diff --git a/include/pybind11/cast.h b/include/pybind11/cast.h index 31f5cb5a6..def3044dc 100644 --- a/include/pybind11/cast.h +++ b/include/pybind11/cast.h @@ -660,7 +660,7 @@ public: std::get<1>(value).load(kwargs, convert); return true; } - + static handle cast(const type &src, return_value_policy policy, handle parent) { return cast(src, policy, parent, typename make_index_sequence::type()); } diff --git a/include/pybind11/pybind11.h b/include/pybind11/pybind11.h index db806b845..690c63549 100644 --- a/include/pybind11/pybind11.h +++ b/include/pybind11/pybind11.h @@ -969,7 +969,7 @@ template struct init { typename std::enable_if::value, int>::type = 0> void execute(pybind11::class_ &class_, const Extra&... extra) const { /// Function which calls a specific C++ in-place constructor - class_.def("__init__", [](Base *self, Args... args) { new (self) Base(args...); }, extra...); + class_.def("__init__", [](Base *self_, Args... args) { new (self_) Base(args...); }, extra...); } template struct init { std::is_constructible::value, int>::type = 0> void execute(pybind11::class_ &class_, const Extra&... extra) const { handle cl_type = class_; - class_.def("__init__", [cl_type](handle self, Args... args) { - if (self.get_type() == cl_type) - new (self.cast()) Base(args...); + class_.def("__init__", [cl_type](handle self_, Args... args) { + if (self_.get_type() == cl_type) + new (self_.cast()) Base(args...); else - new (self.cast()) Alias(args...); + new (self_.cast()) Alias(args...); }, extra...); } @@ -1074,6 +1074,11 @@ template void implicitly_convertible() * can be handy to prevent cases where callbacks issued from an external * thread would otherwise constantly construct and destroy thread state data * structures. + * + * See the Python bindings of NanoGUI (http://github.com/wjakob/nanogui) for an + * example which uses features 2 and 3 to migrate the Python thread of + * execution to another thread (to run the event loop on the original thread, + * in this case). */ class gil_scoped_acquire {