Login | Register   
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


advertisement
 

Use the std::tr1::function Class to Generalize Callbacks

The recently standardized std::tr1::function class template is a generic callback mechanism with intuitive and uniform syntax and semantics. This generalized abstraction mechanism encapsulates any callable entity—regardless of its underlying implementation. Learn how to use this class to simplify your code and expand your design choices.


advertisement
or a C++ programmer, the term "a callback function" means at least three different things: a pointer to a freestanding function (i.e., a C function), a pointer to a member function, or a function object. However, in high level programming, these technical minutiae just get in the way. What you need is a generalized abstraction mechanism that can encapsulate any callable entity regardless of its underlying implementation. The recently standardized std::tr1::function class template offers exactly that. It's a generic callback mechanism with intuitive and uniform syntax and semantics. This article will show you how to use this class template.


How do you generalize the concept of callbacks while maintaining similar syntax and semantics to function pointers?


Use std::tr1::function class template as a generic wrapper for all callable entities.



Comment and Contribute

 

 

 

 

 


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

 

 

Sitemap