I try to write a functor to call a boost function with bind and some template. So i have this main :
int function(char c)
{
std::cout << c << std::endl;
return (0);
}
int main()
{
Function<int (char)> fb = boost::bind(&function, _1);
fb('c');
return (0);
}
and this is my class Function
:
template<typename F>
class Function
{
private:
F functor;
public:
Function()
{
this->functor = NULL;
};
Function(F func)
{
this->functor = func;
};
template <typename P>
void operator()(P arg)
{
(*this->functor)(arg);
};
void operator=(F func)
{
this->functor = func;
};
};
i have a problem : when i try to compile i have these errors :
error C2440: 'initializing' : cannot convert from 'boost::_bi::bind_t<R,F,L>' to 'Function<F>'
IntelliSense: no suitable user-defined conversion from "boost::_bi::bind_t<int, int (*)(char), boost::_bi::list1<boost::arg<1>>>" to "Function<int (char)>" exists
Someone can help me ?