Comments (7)
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?
from 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".
from 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?
from functionalplus.
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.
from 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?
Yes.
Ok, got it.
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?
from functionalplus.
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) {
}
}
from functionalplus.
Ah, thanks. Now I understand.
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:
- https://en.cppreference.com/w/cpp/language/pointer#Pointers_to_member_functions
- https://isocpp.org/wiki/faq/pointers-to-members
- https://stackoverflow.com/questions/37636373/how-stdbind-works-with-member-functions
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.
from functionalplus.
Related Issues (20)
- Clean install rules up? HOT 1
- Reconsider install location HOT 11
- implement either class HOT 2
- implement drop_last_while method HOT 2
- Unit tests always succeeding, even when breaking them on purpose HOT 5
- Consecutive build should only re-build changed files instead of all. (Circular build dependency in CMake setup?) HOT 2
- error: exception handling disabled, use ‘-fexceptions’ to enable HOT 1
- keep_by_idx() returns list of empty elements. HOT 4
- Branch `master` will be renamed to `main` in November HOT 1
- 0.2.16-p0: Tests fail to build: "EQUAL" "1" Unknown arguments specified HOT 10
- Cannot compile with gcc 11.2 in C++20 mode HOT 3
- Add int overrides for (some) size_t params as a convenience for fplus::fwd? HOT 3
- fplus::compose with yet unknown output type HOT 3
- parallel_for ? (no, this is not the 1st of April ;-) HOT 3
- IO Monad HOT 5
- composition.hpp uses std::result_of HOT 5
- Function to print std::tuple HOT 5
- Some List Functions (in particular, fplus::transform etc.) do not work with custom container. What needs to be added? HOT 6
- Clang 16: incompatible initializer of type (container_common_test) HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from functionalplus.