[C++-sig] iterator over list and sequences

Yves Secretan Yves_Secretan at inrs-ete.uquebec.ca
Mon Nov 28 17:46:58 CET 2005


Hello all,

In search for a simple way to iterate in C++ over a boost::python::list, I
only found a discussion about how nice it would be to have one (
http://mail.python.org/pipermail/c++-sig/2003-March/003528.html). So I wrote
a set of C++ iterators and ended up with a syntax a little more complex than
what was originally proposed by David Abrahams, but maybe I missed
something.

typedef value_iterator<int> iter_type;
for (iter_type i = begin<iter_type>(lst);
   i != end<iter_type>();
   ++i)
{
   whatever(*i);
}

The tests provided have been run with gcc 3.3 mingw, visual c++ 7.0 and
Intel 7.1 on WindowsXP (Boost 1.33.0, Python 2.4).

Is there any interest?

---------------------------------------------------------------
Yves Secretan, Professeur
INRS-ETE
490, rue de la Couronne
Québec, Québec
G1K 9A9 CANADA

tel: (418) 654 38 48   fax: (418) 654 26 00
e-mail: Yves_Secretan at ete.inrs.ca
---------------------------------------------------------------

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/cplusplus-sig/attachments/20051128/029655fe/attachment.htm>
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: sequence_iterator.txt
URL: <http://mail.python.org/pipermail/cplusplus-sig/attachments/20051128/029655fe/attachment.txt>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: test_sequence_iterator.cpp
Type: application/octet-stream
Size: 4187 bytes
Desc: not available
URL: <http://mail.python.org/pipermail/cplusplus-sig/attachments/20051128/029655fe/attachment.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: sequence_iterator.hpp
Type: application/octet-stream
Size: 7325 bytes
Desc: not available
URL: <http://mail.python.org/pipermail/cplusplus-sig/attachments/20051128/029655fe/attachment-0001.obj>


More information about the Cplusplus-sig mailing list