#include <iostream>
#include<map>
#include<string>
#include<vector>
struct wrapper{ //wrapper is not a class template anymore
void operator()(std::string (*fun)()) {std::cout<<"wrapped "<<fun()<<std::endl;}
template<typename T>
void operator()(std::string (T::*fun)(), T obj)
{
std::cout<<"wrapped "<<(obj.*fun)()<<std::endl;
}
};
std::string foo() {
return "foo";
}
struct bar{
// static function works:
static std::string str1() { return "bar1";}
wrapper wrapped_bar1;
// Non-static member function does not work:
std::string str2() { return "bar2";}
};
int main() {
wrapper wrapped;
wrapped(foo);
bar some_bar;
some_bar.wrapped_bar1(&bar::str1);
some_bar.wrapped_bar1(&bar::str2, some_bar);
}