Skip to content

Unable to wrap a function that's called with an enum #5492

Answered by luigibrancati
smurfix asked this question in Q&A
Discussion options

You must be logged in to vote

Hi @smurfix,

I have been looking at this issue. This seems to be caused by the fact that when compiling the wrapped function, the compiler only generates the template instance wrap<int, int, int, xfoo>(int&&, int&&, xfoo&&) which is what you would expect in C++ by the resolution of the universal reference. However, pybind11 tries to pass the enums as lvalue so it looks for wrap<int, int, int, xfoo>(int, int, xfoo&), which hasn't been instantiated by the compiler.

I've attempted multiple solutions (see below), but most of them ultimately require to provide pybind11 with a non-templated function or operator() so that it can correctly infer its signature with decltype(&F::operator()), which …

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by smurfix
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants