Giter Club home page Giter Club logo

Comments (7)

Dobiasd avatar Dobiasd commented on June 9, 2024

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.

nblog avatar nblog commented on June 9, 2024

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.

Dobiasd avatar Dobiasd commented on June 9, 2024

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.

nblog avatar nblog commented on June 9, 2024

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.

Dobiasd avatar Dobiasd commented on June 9, 2024

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.

nblog avatar nblog commented on June 9, 2024

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_ptrreally 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.

Dobiasd avatar Dobiasd commented on June 9, 2024

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:


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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.