The std::pointer_to_unary_function Template

The std::pointer_to_unary_function Template

The Standard Library defines several template adaptors for function pointers. The std::pointer_to_unary_function class template encapsulates a pointer to a single argument function. std::pointer_to_unary_function overloads the () operators so that you can use an instance of this template as a function. In the following example, this template serves as a wrapper for the function strlen(). The template arguments, namely const char * and size_t, are the bound function’s argument and return type, respectively (strlen() takes a const char * and returns a value of type size_t):

 #include  // for strlen#include  // for pointer_to_unary_functionusing namespace std;int main(){ char name[]=


Share the Post: