#include <iostream>
using namespace std;
struct Foo
{
void Bar(int a)
{
cout<<"non-const "<<a<<endl;
}
void BarConst(int a) const
{
cout<<"const "<<a<<endl;
}
};
struct CallMe
{
template<class This, class F, class... Args>
void Invoke(This *obj, F&& f, Args&&... args) const
{
// Do something need the Return, This, Args... types..
(obj->*std::forward<F>(f))(std::forward<Args>(args)...);
}
};
int main() {
CallMe call;
Foo f;
call.Invoke(&f, &Foo::Bar, 1);
call.Invoke(&f, &Foo::BarConst, 1);
// your code goes here
return 0;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgp1c2luZyBuYW1lc3BhY2Ugc3RkOwoKc3RydWN0IEZvbwp7Cgl2b2lkIEJhcihpbnQgYSkKCXsKCQljb3V0PDwibm9uLWNvbnN0ICI8PGE8PGVuZGw7Cgl9Cgl2b2lkIEJhckNvbnN0KGludCBhKSBjb25zdAoJewoJCWNvdXQ8PCJjb25zdCAiPDxhPDxlbmRsOwoJfQp9OwpzdHJ1Y3QgQ2FsbE1lCnsKCXRlbXBsYXRlPGNsYXNzIFRoaXMsIGNsYXNzIEYsIGNsYXNzLi4uIEFyZ3M+Cgl2b2lkIEludm9rZShUaGlzICpvYmosIEYmJiBmLCBBcmdzJiYuLi4gYXJncykgY29uc3QKCXsKCQkvLyBEbyBzb21ldGhpbmcgbmVlZCB0aGUgUmV0dXJuLCBUaGlzLCBBcmdzLi4uIHR5cGVzLi4KCQkob2JqLT4qc3RkOjpmb3J3YXJkPEY+KGYpKShzdGQ6OmZvcndhcmQ8QXJncz4oYXJncykuLi4pOwoJfQp9OwppbnQgbWFpbigpIHsKCUNhbGxNZSBjYWxsOwoJRm9vIGY7CgljYWxsLkludm9rZSgmZiwgJkZvbzo6QmFyLCAxKTsKCWNhbGwuSW52b2tlKCZmLCAmRm9vOjpCYXJDb25zdCwgMSk7CgkvLyB5b3VyIGNvZGUgZ29lcyBoZXJlCglyZXR1cm4gMDsKfQ==