Login | Register   
LinkedIn
Google+
Twitter
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX


Tip of the Day
Home » Tip Bank » C++
Language: C++
Expertise: Advanced
Jul 2, 2001

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 <cstring> // for strlen
#include <functional> // for pointer_to_unary_function
using namespace std;
int main()
{
 char name[]=
Danny Kalev
 
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Sitemap
Thanks for your registration, follow us on our social networks to keep up-to-date