Last active
December 29, 2015 04:20
-
-
Save xaxxon/1683f166b630a87ebe2f to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <list> | |
template<typename F> class Caller { | |
public: | |
F func; | |
Caller(T func) : func(func) {} | |
void call(MyClass o, list<int>, Ts... ts) { | |
o.func(ts...); | |
} | |
}; | |
template<typename F, typename RET, typename HEAD, typename TAIL> | |
class Caller<F, RET(HEAD,TAIL...)> : Caller<T, RET(TAIL...)> { | |
public: | |
typedef Caller<RET(TAIL)> super; | |
typedef HEAD Head; | |
Caller(F func):super(func) {} | |
void call(MyClass o, std::list<int> l, Ts... ts) { | |
HEAD head = l.first; | |
l.pop_front(); | |
this->super::call(o, list, head, ts...); | |
} | |
}; | |
class MyClass {public: void foo(int,int){}}; | |
MyClass my_object; | |
std::list<int> ints = {1,2}; | |
Caller caller(&MyClass::foo, &MyClass::foo); // I can make a helper to make this better | |
caller.call(my_object, ints); // this should run my_object.foo(1,2); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This code is pseudo-c++ to call a method with parameters presented in a list. Is it anywhere near something that could work?