c++模板之函数指针到函数对象:

xiaoxiao2021-02-28  86

template<class R,class ARG> class pointer_to_unary_function<R,ARG> { R (*p)(ARG); public: explicit pointer_to_unary_function(R (*px)(ARG)):p(px){ } }

 

 整个过程巧妙之处就在那个参数传递上,参数传递发生类型识别,类型识别后直接初始化模板参数。

 

 然后又通过typedef 进行类型定义。。

 

 

 

 

 

 

 

转载请注明原文地址: https://www.6miu.com/read-72472.html

最新回复(0)