File tree Expand file tree Collapse file tree 1 file changed +9
-4
lines changed
include/boost/python/suite/indexing Expand file tree Collapse file tree 1 file changed +9
-4
lines changed Original file line number Diff line number Diff line change 77#ifndef PY_CONTAINER_UTILS_JDG20038_HPP
88# define PY_CONTAINER_UTILS_JDG20038_HPP
99
10+ # include < utility>
11+ # include < boost/foreach.hpp>
1012# include < boost/python/object.hpp>
1113# include < boost/python/handle.hpp>
1214# include < boost/python/extract.hpp>
15+ # include < boost/python/stl_iterator.hpp>
1316
1417namespace boost { namespace python { namespace container_utils {
1518
@@ -19,11 +22,13 @@ namespace boost { namespace python { namespace container_utils {
1922 {
2023 typedef typename Container::value_type data_type;
2124
22- // l must be a list or some container
23-
24- for (int i = 0 ; i < l.attr (" __len__" )(); i++)
25+ // l must be iterable
26+ BOOST_FOREACH (object elem,
27+ std::make_pair (
28+ boost::python::stl_input_iterator<object>(l),
29+ boost::python::stl_input_iterator<object>()
30+ ))
2531 {
26- object elem (l[i]);
2732 extract<data_type const &> x (elem);
2833 // try if elem is an exact data_type type
2934 if (x.check ())
You can’t perform that action at this time.
0 commit comments