[C++-sig] wrapping a custom C++ iterator

David Abrahams dave at boost-consulting.com
Fri Sep 13 18:38:56 CEST 2002


From: "Ralf W. Grosse-Kunstleve" <rwgk at yahoo.com>
> 
> OK, thanks for pointing this out! I changed my code:
> 
> 1.
>     static boost::python::object iter(boost::python::object const& o)
>     {
>       return o;
>     }
> 
> 2.
>         .def("__iter__", iter)
>     
> In Python this works now:
> 
>   i = sgtbx.space_group_symbol_iterator()
>   assert id(i) == id(iter(i))
> 
> Is this approach technically OK?

I guess so. It seems like it should be.

-----------------------------------------------------------
           David Abrahams * Boost Consulting
dave at boost-consulting.com * http://www.boost-consulting.com







More information about the Cplusplus-sig mailing list