-
Notifications
You must be signed in to change notification settings - Fork 2.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Intersection of overloads and std::function<> #1085
Comments
Quick note: you must be compiling in C++14, or at least with a C++14 supporting compiler, in order for the compiler to be able to tell the difference between differing signatures in |
Wouldn't the problem be that a Python function cannot 'match a typed overload', in general, because of Python's duck-typing? |
yep, I am (using g++ 7.2).
hmm... yes, that would make sense. If I understand correctly, there is a single "function" type from Python's side ? |
I think so. Or not even, actually. There's just 'things that can be called' (i.e., I'm guessing you could perfectly pass an object with the On the other hand, doesn't Python allow some kind of introspection, either? But then I don't know if pybind uses that. |
Answer: nope, looking at if (!isinstance<function>(src))
return false;
// ...
value = [func](Args... args) -> Return {
gil_scoped_acquire acq;
object retval(func(std::forward<Args>(args)...));
/* Visual studio 2015 parser issue: need parentheses around this expression */
return (retval.template cast<Return>());
}; |
okay, I guess I'll just give my function another name ! thanks |
I'd like to have multiple overloads that take different kinds of functions in parameters:
But the following python code fails:
with:
The first overload works, and renaming the second overload to another function name (for instance add_callback2) works too.
Is there a way around this ?
The text was updated successfully, but these errors were encountered: