Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- class CallBase {
- public:
- virtual ~CallBase () {}
- template <typename F, typename... A>
- void callBaseFunction (F func, A... args) {
- func(args...);
- }
- };
- template<typename F>
- class Call : public CallBase {
- private:
- F func;
- public:
- Call (F func) : func(func) {}
- ~Call () {}
- template <typename... A>
- void call (A... args) {
- callBaseFunction(func, args...);
- }
- };
- class Test {
- private:
- CallBase* callBase;
- public:
- template<typename F, typename... A>
- Test (F func, A... args) {
- callBase = new Call<F>(func);
- ((Call<F>*)callBase)->call(args...);
- }
- ~Test () {
- delete callBase;
- }
- };
- void f (int a) {
- std::cout << a << std::endl;
- }
- int main () {
- Test testA(f, 2);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement