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

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 进行类型定义。。

 

 

 

 

 

 

 

你可能感兴趣的:(C++,c,C#)