Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cython std::pair of two pointers, expected an identifier or literal

Why in Cython is possible to wrap

std::pair<int, Foo*> myPair;

but not

std::pair<Foo*,Bar*> myPair;

In particular, wrapping in Cython the std::pair is done as follows:

pair[int, Foo*]

and works smoothly, but when the first element of is also a pointer I have problems:

pair[Foo*,Bar*] myPair2

I'm getting

pair[Foo*,Bar*] myPair2
        ^
------------------------------------------------------------
test.pyx:50:17: Expected an identifier or literal

I'm using Cython 0.17.1, g++ 4.4 on Linux

like image 974
linello Avatar asked Nov 06 '12 10:11

linello


1 Answers

The types are treated the same in the pair definition; it is probably a general limitation for the [] syntax. You could try to workaround it with a typedef: ctypedef Foo* Foo_pointer

Copy pasted from a comment by @J.F.Sebastian so that this question can be marked as answered (to hopefully clear up the list of unanswered questions -- it has been a month!)

like image 173
Yakk - Adam Nevraumont Avatar answered Oct 16 '22 07:10

Yakk - Adam Nevraumont