Skip to content

How to initialize delegate with function pointer #2

@quangr

Description

@quangr

Dear Matthew Rodusek, THANKS for writing such an amazing blog about how to creating delegate type in c++. It really helps a lot. I'm trying to create a timer with a function pointer. I want it to do something like this.

void Task(int a){}
Timer<&task,1000> timer;

However, after mimic the delegate type, the best I can do is something like this.

Timer<decltype(Task)> timer{1000};
timer.bind<&Task>();

I'm wondering if there's something that I can do to bind the function pointer in constructor in C++11. I'm really hoping to get some advice from a c++ expert like you. THANKS again for your fascinating post.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions