Cython std::pair of two pointers, expected an iden

2019-04-24 06:07发布

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

1条回答
叛逆
2楼-- · 2019-04-24 06:34

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!)

查看更多
登录 后发表回答