Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <functional>
- int f1(int a, int b, bool c)
- {
- return c ? a + b : a - b;
- }
- int f2(int a )
- {
- return a * 2;
- }
- int f3(){
- return 0;
- }
- void f4(){
- int a;
- int b;
- }
- template <typename R, typename... Args>
- R call(void* funcaddr, Args... args)
- {
- typedef R(*Function)(Args...);
- Function fnptr = (Function)funcaddr;
- return fnptr(args...);
- }https://pastebin.com/
- int main(){
- call<int>( (void*)f1, 42, 10, true);
- call<int>( (void*)f2, 42 );
- call<int>( (void*)f3 );
- call<void>( (void*)f4 );
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement