diff --git a/include/pybind11/pybind11.h b/include/pybind11/pybind11.h index 4706b6f7c..8a3907ef8 100644 --- a/include/pybind11/pybind11.h +++ b/include/pybind11/pybind11.h @@ -1006,7 +1006,7 @@ template iterator make_iterator(Iterator if (!detail::get_type_info(typeid(state))) { class_(handle(), "") .def("__iter__", [](state &s) -> state& { return s; }) - .def("__next__", [](state &s) -> decltype(*std::declval()) & { + .def("__next__", [](state &s) -> decltype(*std::declval()) { if (s.it == s.end) throw stop_iteration(); return *s.it++; diff --git a/include/pybind11/pytypes.h b/include/pybind11/pytypes.h index c9eaa40ec..5a512fae1 100644 --- a/include/pybind11/pytypes.h +++ b/include/pybind11/pytypes.h @@ -285,7 +285,7 @@ public: bool operator==(const iterator &it) const { return *it == **this; } bool operator!=(const iterator &it) const { return *it != **this; } - const handle &operator*() const { + handle operator*() const { if (!ready && m_ptr) { auto& self = const_cast(*this); self.advance();