Ok, thank you responding me !
My example was just here as "proof" of what i need.
My idea is to encapsulate a boost::function of any type in a template
class, which herite from a pure virtual class FooVirtual.
My goal is to transform any function into a FooVirtual* using an
helper function.
I realize my last message was not very clear, here is a better example
#include <iostream>
#include <stdexcept>
#include
#include
template
boost::function mybind(Ret (*Func)(Arg1))
{
boost::function f(Func) ;
return f ;
}
void bar() {}
void bar2(int a) {}
int main (int argc, char* argv[])
{
try
{
boost::function < void ()> f1( boost::bind(&bar) ) ;
boost::function < void (int) > f2( boost::bind(&bar2,_1) ) ;
// doesn't work :
// boost::function < void (int) > f2( boost::bind(&bar2) ) ;
// this is ok
boost::function < void (int) > f3( mybind(&bar2) ) ;
}
catch(std::exception& e)
{
std::cout << e.what() << '\n' ;
return -1 ;
}
catch(...)
{
std::cout << "Non standard exception\n" ; return -1 ;
}
}