Code Monkey home page Code Monkey logo

delegate's Introduction

const AUTHOR: &'static github::Author = github::author!()

println!("{}", AUTHOR.greeting());

๐Ÿ‘‹ Hi, I'm @bitwizeshift. By day, I'm a professional Go developer with Verily. By night, I'm a C++ developer with over a decade of experience, a Rust developer/enthusiest, a Software blogger, and hobbiest open-source creator.

I like solving hard problems in fun and interesting ways. Check out some of my projects!

If you like any of my work, please consider becoming a Github sponsor or even just buying me a coffee!

Github stats for bitwizeshift

delegate's People

Contributors

bitwizeshift avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

wsgeek

delegate's Issues

Are capturing lambdas supported?

With the default configuration the following code segfaults:

TEST_CASE("Delegate test with large capture")
{
    int a = 0, b, c, d;
    delegate::Delegate<void> test([&a, &b, &c]()
    {
        a = 1;
    });

    test();

    REQUIRE(a == 1);
}

Until I increase DELEGATE_ARGS_SIZE.

#define DELEGATE_ARGS_SIZE sizeof(int) + sizeof(int *) /* + N */

So it seems to work when the capturing lambda only captures 2 words worth of memory. Is this working as intended?
Or should I expect lambdas of any size to fail at some point in the future for me?

Thanks!

How to initialize delegate with function pointer

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.

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.