diff --git a/include/boost/python/suite/indexing/container_utils.hpp b/include/boost/python/suite/indexing/container_utils.hpp index a25185d0..72710bb8 100644 --- a/include/boost/python/suite/indexing/container_utils.hpp +++ b/include/boost/python/suite/indexing/container_utils.hpp @@ -7,9 +7,12 @@ #ifndef PY_CONTAINER_UTILS_JDG20038_HPP # define PY_CONTAINER_UTILS_JDG20038_HPP +# include +# include # include # include # include +# include namespace boost { namespace python { namespace container_utils { @@ -19,11 +22,13 @@ namespace boost { namespace python { namespace container_utils { { typedef typename Container::value_type data_type; - // l must be a list or some container - - for (int i = 0; i < l.attr("__len__")(); i++) + // l must be iterable + BOOST_FOREACH(object elem, + std::make_pair( + boost::python::stl_input_iterator(l), + boost::python::stl_input_iterator() + )) { - object elem(l[i]); extract x(elem); // try if elem is an exact data_type type if (x.check())