Jackson Hoy Loper wrote:
> On Thu, Oct 23, 2008 at 5:34 PM, Hoy Loper <[EMAIL PROTECTED]> wrote:
>   
>>> As for things like C++ iterators, you can use them as
>>> long as you're willing to heap-allocate them and explicitly
>>>       
>> Alas, not strictly true.  STL containers don't return pointers to
>> iterators, they return iterators themselves.  And they're not lvalues,
>> so you can't take their address.  One sometimes rather needs to be
>> able to handle the data itself, rather than a pointer to it.  I know
>> it is unpythonic, but that's the way STL is built.  Or possibly I am
>> missing something :).
>>     

Here's a full example:

// Declare at top
std::vector<int>::const_iterator* p_it, * p_end;
...
// Want to loop
p_it = new std::vector<int>::const_iterator(coll.begin()) # Invokes copy 
constructor
p_end = new std::vector<int>::const_iterator(coll.end())
while (*p_it != *p_end) {
    std::cout << **p_it << std::endl;
    (*p_it)++;
}
delete p_it; delete p_end;

Dag Sverre

_______________________________________________
Cython-dev mailing list
[email protected]
http://codespeak.net/mailman/listinfo/cython-dev

Reply via email to