Closed nblog closed 2 years ago
Hi,
so you have this library with a C function in its interface, but what do you want to do with it using FunctionalPlus?
In case you want to pass it around to C++ functions, wrapping it in a lambda seems like a good idea.
What do you mean by "it was not the best result"?
is this feature suitable for join?
With "join", you mean, you'd like to create a pull request to have something merged into the master
branch of FunctionalPlus?
What do you mean by "it was not the best result"?
I hope is a class:: method. but, I don’t know what to do
class mycls
{
public:
~mycls() { };
mycls() {
test1(
make_function_ptr(this->my_callback);
);
};
void my_callback(int a) {
}
}
With "join", you mean, you'd like to create a pull request to have something merged into the master branch of FunctionalPlus?
Yes, I think it is a good function, but I don’t know if it meets the "FunctionalPlus".
I hope is a class:: method. but, I don’t know what to do
Can't you just use a "normal" free function instead of a member function?
Yes, I think it is a good function, but I don’t know if it meets the "FunctionalPlus".
Ah, so you propose to add your make_function_ptr
(and convert_lambda
) to the library so that an arbitrary C++ function can be converted to a C compatible function pointer. Is this correct?
Can't you just use a "normal" free function instead of a member function?
Yes. can only use lambda
function.
Ah, so you propose to add your make_function_ptr (and convert_lambda) to the library so that an arbitrary C++ function can be converted to a C compatible function pointer. Is this correct?
Yes.
Ah, so you propose to add your make_function_ptr (and convert_lambda) to the library so that an arbitrary C++ function can be converted to a C compatible function pointer. Is this correct?
Yes.
Ok, got it. :slightly_smiling_face:
However, I still would like to understand, what you meant by the following:
i found a way to solve it, but it was not the best result.
If your solution is not the best result, I hesitate to put it into the library. What do you think is wrong with the result?
I also don't get the following:
I hope is a class:: method. but, I don’t know what to do
Does your proposed solution solve it, or are you still looking for a solution?
If your solution is not the best result, I hesitate to put it into the library. What do you think is wrong with the result?
make_function_ptr
really useful, but can be seen from the code that it only supports lambda
function.
Does your proposed solution solve it, or are you still looking for a solution?
using lambda
, I did get the desired result.
but I will continue to look for ways to achieve the following effect, let it support the member functions in the class.
like make_function_ptr_plus
? 😋:
class mycls
{
public:
~mycls() { };
mycls() {
test1(
make_function_ptr_plus(this->my_callback);
);
};
void my_callback(int a) {
}
}
Ah, thanks. Now I understand. :+1:
A pointer to a static member function would be no problem, but the problem with using a "normal" member function this way is, that a member function not only takes the int a
parameter but also the explicit this
parameter, which you have to bind.
Maybe the following three links can be of help:
I'm not yet sure if it would make sense to add make_function_ptr
(and convert_lambda
) to FunctionalPlus though since FunctionalPlus up to now is not really concerned with C interoperability.
hi, please allow me non-standard english.
i encountered a situation on a project:
third party provides C interface:
i used c++ class in my own project
i found a way to solve it, but it was not the best result. callback using lambda with closures
is this feature suitable for join?