#include <proton/string.hpp>
using namespace std;
using namespace proton;
typedef unsigned int (_str2int)(const char*);
typedef func_<_str2int> str2int;
typedef fp_<_str2int> str2int_fp;
struct _f1: fo_<_str2int>{
unsigned int operator()(const char* s)
{
return string(s).size();
}
};
struct _t1{
unsigned int f(const char* s)
{
return strlen(s);
}
};
typedef fm_<t1, _str2int> str2int_fm;
int main()
{
cout << ">>> functor examples :" << endl;
str2int a;
a=b;
cout << "fo is " << a("abc") << endl;
str2int_fp c(strlen);
a=c;
cout << "strlen through fp is " << a("abc") << endl;
str2int_fp d([](const char* s){return strlen(s);});
a=d;
cout << "lambda through fp is " << a("abc") << endl;
t1 x;
str2int_fm e(x, &_t1::f);
a=e;
cout << "member function through fm is " << a("abc") << endl;
return 0;
}