Skip to content

Commit 52245de

Browse files
committed
Andreas patch
[SVN r44449]
1 parent 2f1f79c commit 52245de

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

include/boost/python/suite/indexing/container_utils.hpp

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,12 @@
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

1417
namespace 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())

0 commit comments

Comments
 (0)