|
Boost-Commit : |
From: joel_at_[hidden]
Date: 2008-04-15 23:07:06
Author: djowel
Date: 2008-04-15 23:07:06 EDT (Tue, 15 Apr 2008)
New Revision: 44449
URL: http://svn.boost.org/trac/boost/changeset/44449
Log:
Andreas patch
Text files modified:
trunk/boost/python/suite/indexing/container_utils.hpp | 13 +++++++++----
1 files changed, 9 insertions(+), 4 deletions(-)
Modified: trunk/boost/python/suite/indexing/container_utils.hpp
==============================================================================
--- trunk/boost/python/suite/indexing/container_utils.hpp (original)
+++ trunk/boost/python/suite/indexing/container_utils.hpp 2008-04-15 23:07:06 EDT (Tue, 15 Apr 2008)
@@ -7,9 +7,12 @@
#ifndef PY_CONTAINER_UTILS_JDG20038_HPP
# define PY_CONTAINER_UTILS_JDG20038_HPP
+# include <utility>
+# include <boost/foreach.hpp>
# include <boost/python/object.hpp>
# include <boost/python/handle.hpp>
# include <boost/python/extract.hpp>
+# include <boost/python/stl_iterator.hpp>
namespace boost { namespace python { namespace container_utils {
@@ -19,11 +22,13 @@
{
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<object>(l),
+ boost::python::stl_input_iterator<object>()
+ ))
{
- object elem(l[i]);
extract<data_type const&> x(elem);
// try if elem is an exact data_type type
if (x.check())
Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk