Skip to content

Instantly share code, notes, and snippets.

@ofan
Created August 31, 2013 17:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ofan/6399618 to your computer and use it in GitHub Desktop.
Save ofan/6399618 to your computer and use it in GitHub Desktop.
#include <iostream>
int doAdd(int (*call)(int,int)) {
return call(1,2);
}
int main() {
struct Add {
static int add(int a, int b) {
return a + b;
}
};
std::cout << doAdd(Add::add) << std::endl;
return 0;
}
@ofan
Copy link
Author

ofan commented Aug 31, 2013

int doAdd(int (_call)(int,int)) {
struct closure{
closure(int (_c)(int,int)):m_callback(c);

    static int operator()(int a, int b);
    private:
        static int (*m_callback)(int,int);
};
closure cl(call);
return cl(1,2);

}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment