#include #include "macro.h" #include "typelist.h" #include "service.h" #include "functor.h" double FunctorTest( float arg1, int arg2, char *arg3 ) { printf( "%-8s : (%.2f + 1) * %2d = ", arg3, arg1, arg2 ); return double((arg1+1) * arg2); } template< typename Func > double FunctorCallTest( Func f ) { return f(5.0f, "call"); } void main() { Functor functorFactory; char str[] = "hoge"; // bind テスト printf( "%6.2f\n", functorFactory(FunctorTest, Binder::unbind, 10, str )( 1.23f ) ); printf( "%6.2f\n", functorFactory(FunctorTest, 2.46f, Binder::unbind, str )( 5 ) ); printf( "%6.2f\n", functorFactory(FunctorTest, 3.69f, 3, Binder::unbind)( "hogehoge" ) ); // bind することで違う関数を生成しているのを試すテスト printf( "%6.2f\n", FunctorCallTest( functorFactory(FunctorTest, Binder::unbind, 20, Binder::unbind) ) ); }