文件名称:myTestFunctor
介绍说明--下载内容均来自于网络,请自行研究使用
c++ 的 functor实现,支持c函数和成员函数,使用非常简单,源码带使用例子
包含头函数:#include "Functor.h"
初始化c函数指针 Functor< int, int, int, int, int, int > fun1( &FuncSum )
printf( "fun1: d\n", fun1.Exec( 1, 2, 3, 4, 5 ) )
Functor< int, int, int, int, int, int > fun2
fun2 = Functor< int, int, int, int, int, int >( &FuncSum )
fun2 = fun1
成员函数初始化:
Fool myObj
fun3 = Functor< int, float, float >( &myObj, &Fool::CallMethod )
if ( fun3 )
{
printf( "fun3 is not null......\n" )
}
else
{
printf( "fun3 is null......\n" )
}
if ( fun3 )
{
printf( "fun3 result is: d\n", fun3( 1.2f, 2.1f ) )
}-c++ implementation of the functor, support c functions and member functions, using a very simple source code with the use of examples include the first function:# include " Functor.h" initialization c function pointer Functor < int, int, int, int, int, int > fun1 (& FuncSum) printf ( " fun1: d \ n" , fun1.Exec (1, 2, 3, 4, 5)) Functor < int, int, int, int, int, int> fun2 fun2 = Functor < int, int, int, int, int, int> (& FuncSum) fun2 = fun1 member function to initialize: Fool myObj fun3 = Functor < int, float, float> (& myObj, & Fool:: CallMethod) if (fun3) (printf ( " fun3 is not null ...... \ n" ) ) else (printf ( " fun3 is null ...... \ n" ) ) if (fun3) ( printf ( " fun3 result is: d \ n" , fun3 (1.2f, 2.1f)) )
包含头函数:#include "Functor.h"
初始化c函数指针 Functor< int, int, int, int, int, int > fun1( &FuncSum )
printf( "fun1: d\n", fun1.Exec( 1, 2, 3, 4, 5 ) )
Functor< int, int, int, int, int, int > fun2
fun2 = Functor< int, int, int, int, int, int >( &FuncSum )
fun2 = fun1
成员函数初始化:
Fool myObj
fun3 = Functor< int, float, float >( &myObj, &Fool::CallMethod )
if ( fun3 )
{
printf( "fun3 is not null......\n" )
}
else
{
printf( "fun3 is null......\n" )
}
if ( fun3 )
{
printf( "fun3 result is: d\n", fun3( 1.2f, 2.1f ) )
}-c++ implementation of the functor, support c functions and member functions, using a very simple source code with the use of examples include the first function:# include " Functor.h" initialization c function pointer Functor < int, int, int, int, int, int > fun1 (& FuncSum) printf ( " fun1: d \ n" , fun1.Exec (1, 2, 3, 4, 5)) Functor < int, int, int, int, int, int> fun2 fun2 = Functor < int, int, int, int, int, int> (& FuncSum) fun2 = fun1 member function to initialize: Fool myObj fun3 = Functor < int, float, float> (& myObj, & Fool:: CallMethod) if (fun3) (printf ( " fun3 is not null ...... \ n" ) ) else (printf ( " fun3 is null ...... \ n" ) ) if (fun3) ( printf ( " fun3 result is: d \ n" , fun3 (1.2f, 2.1f)) )
(系统自动生成,下载前可以参看下载内容)
下载文件列表
TestFunctor.vcproj
TestFunctor.vcproj.PC-200901081558.Administrator.user
TestFunctor.vcproj.PERSONAL-6EF27B.zmy.user
TestFunctor.sln
TestFunctor.suo
Functor.h
FunctorBase.h
GlobalFunctor.h
MemberFunctor.h
ReadMe.txt
stdafx.cpp
stdafx.h
TestFunctor.cpp
TestFunctor.vcproj.PC-200901081558.Administrator.user
TestFunctor.vcproj.PERSONAL-6EF27B.zmy.user
TestFunctor.sln
TestFunctor.suo
Functor.h
FunctorBase.h
GlobalFunctor.h
MemberFunctor.h
ReadMe.txt
stdafx.cpp
stdafx.h
TestFunctor.cpp