[Cython] wrapping c++

Neal Becker ndbecker2 at gmail.com
Wed Mar 5 12:09:33 CET 2008


On Wednesday 05 March 2008, Stefan Behnel wrote:
> Neal Becker wrote:
> > Is operator the real issue here?  In the std::vector example, there is
> > 'at',
> > which does (almost) the same thing as operator[].  My problem is that
> > both 'at' and 'operator[]' return int&, and to use them you need to
> > say 'at[i]=j', which I don't know how to do in cython (except for the
> > macro
> > version above,  or to write additional wrapper code in more c++ headers).
>
> If you declare a variable
>
>     cdef int* myvar
>
> Cython allows you to say
>
>     myvar[5] = 1
>
> Is that what you want?
>
> Stefan

Does that help for a function that returns int&?

Let's say we have a c++ class intvec, it has
int& at(int index);


More information about the Cython-dev mailing list