Support for cdef of C++ object references
See original GitHub issueWhen a C++ function returns a reference we are forced to workaround: typically make the call inside a function accepting references
It would be desirable to support
cdef Foo & obj = func_bar()
Cython apparently declares the reference and assigns to it in different steps, which obviously doesn’t compile.
Issue Analytics
- State:
- Created 6 years ago
- Comments:5 (2 by maintainers)
Top Results From Across the Web
Borrowed reference to cdef class? - Google Groups
Basically, how do I do that? I cannot find it in the documentation. Say I have a cdef class like this: cdef class...
Read more >Language Basics — Cython 3.0.0a11 documentation
C functions are defined using the cdef statement in Cython syntax or with the @cfunc decorator. They take either Python objects or C...
Read more >References in C++ - GeeksforGeeks
C ++ · 1) Once a reference is created, it cannot be later made to reference another object; it cannot be reset. This...
Read more >How to interface a c++ function that returns a reference to an ...
we would get the following generated C-code for the line cdef int * first=&(vect.at(0)) (only important parts): static PyObject *__ ...
Read more >Reference declaration - cppreference.com
Concurrency support library (C++11) ... namespace alias definition ... as a reference, that is, an alias to an already-existing object or ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
The
cdef Foo* obj = &func_bar()
trick only works when func_bar returns a reference. It is correct that an assignment invokes the assignment operator.I was wondering if cython was specially handling that case, but no, it doesn’t work.
...xxx:165:34: Taking address of non-lvalue (type Positions)