From 146397ecf47db162465a4d02b5c7862d4784e3c7 Mon Sep 17 00:00:00 2001 From: Wenzel Jakob Date: Tue, 6 Sep 2016 13:06:31 +0900 Subject: [PATCH] allow iterators with different RV policies (fixes #388) --- include/pybind11/pybind11.h | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/include/pybind11/pybind11.h b/include/pybind11/pybind11.h index b35b2fc7..7bdf9137 100644 --- a/include/pybind11/pybind11.h +++ b/include/pybind11/pybind11.h @@ -1123,7 +1123,7 @@ PYBIND11_NOINLINE inline void keep_alive_impl(int Nurse, int Patient, handle arg keep_alive_impl(nurse, patient); } -template +template struct iterator_state { Iterator it; Sentinel end; @@ -1139,10 +1139,10 @@ template ()), typename... Extra> iterator make_iterator(Iterator first, Sentinel last, Extra &&... extra) { - typedef detail::iterator_state state; + typedef detail::iterator_state state; if (!detail::get_type_info(typeid(state))) { - class_(handle(), "") + class_(handle(), "iterator") .def("__iter__", [](state &s) -> state& { return s; }) .def("__next__", [](state &s) -> ValueType { if (!s.first) @@ -1157,15 +1157,16 @@ iterator make_iterator(Iterator first, Sentinel last, Extra &&... extra) { return (iterator) cast(state { first, last, true }); } + template ()).first), typename... Extra> iterator make_key_iterator(Iterator first, Sentinel last, Extra &&... extra) { - typedef detail::iterator_state state; + typedef detail::iterator_state state; if (!detail::get_type_info(typeid(state))) { - class_(handle(), "") + class_(handle(), "iterator") .def("__iter__", [](state &s) -> state& { return s; }) .def("__next__", [](state &s) -> KeyType { if (!s.first)