[Cython] C++ STL iteration bugs

Robert Bradshaw robertwb at gmail.com
Sun Aug 12 07:12:39 CEST 2012


On Sat, Aug 11, 2012 at 10:03 PM, Robert Bradshaw <robertwb at gmail.com> wrote:
> On Sat, Aug 11, 2012 at 1:19 PM, Stefan Behnel <stefan_ml at behnel.de> wrote:
>> Hi,
>>
>> I ran into a couple of problems with the new C++ STL integration, just
>> dumping them here for now.
>>
>> Invalid C code when using a stack allocated C++ vector inside of a
>> generator, also lacking type conversion utility code:
>>
>> https://github.com/cython/cython/commit/d0a8e24720c3ed4e723b5a1b204bf375780f51bd
>>
>> Failure to compile iteration over pointer to C++ vector, apparently a type
>> inference bug:
>>
>> https://github.com/cython/cython/commit/edd10c3b33afcac8f471ac6d6664e29f2d985d21

Well, the problem is that you're trying to iterate over a
vector[int]*, and iteration over pointers already has a meaning. Given
v of type vector[int]*, it would be nice to support both iteration
over v[a:b] and v (element-wise over the pointed-to vector), but I
don't think this is a bug per se. (There is similar ugliness with
operator overloading, e.g. given "cdef CppClass* x" should "x + 1"
increments the pointer rather than operator+.)

- Robert


More information about the cython-devel mailing list