Cannot bind std::bind/std::mem_fn(/std::function) although lambda can be bound #3612
Unanswered
cielavenir
asked this question in
Q&A
Replies: 1 comment
-
This worked for my case: template<typename R, typename C, typename... Args>
struct FirstArgReturner
{
template<void (C::*F)(R&, Args...)>
static R func(C& inst, Args... args)
{
/*
Let F is a member function which returns void and the first argument is reference.
Now these two have the same meaning:
1. FirstArgReturner<R,C,Args...>::with(&C::F)
2. [](C& inst, Args... args){
R r;
C.F(r, args...);
return r;
}
*/
R r;
(inst.*F)(r, args...);
return r;
}
};
def("f1", &FirstArgReturner<int, C, int, int>::func<&C::f>) |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
This code works:
However this code (f1) does not compile (even though f2 compiles):
what I see is:
is this spec or bug of pybind11('s resolver)?
my first intention is this:
Beta Was this translation helpful? Give feedback.
All reactions