1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
|
#include <iostream>
#include <boost/function.hpp>
class A
{
public:
void MaMethode(int,int){std::cout<<"coucou"<<std::endl;}
};
template<class T>
void invoquer_un_a(A a,T t_)
{
t_(&a,1,1);
}
template<class T,class R, class Arg1, class Arg2>
boost::function3<R, T*,Arg1,Arg2> make_boost_function(R (T::*t)(Arg1,Arg2))
{
boost::function3<R, T*,Arg1,Arg2> func;
func = t;
return func;
};
int main()
{
invoquer_un_a(A(),make_boost_function(&A::MaMethode));
// au lieu de :
invoquer_un_a(A(),boost::function<void (A*,int,int)>(&A::MaMethode));
return 0;
} |
Partager