June From the Pages Features
Wrapping C++ Member Function Calls
This article presents a simple, general, and efficient solution for wrapping calls to member functions of a class in pairs of prefix and suffix code. The solution is nonintrusive, applies to existing classes, allows the use of several prefix/suffix pairs, and can be implemented in 15 simple lines of Standard C++. Stroustrup organizes his discussion around a series of examples, evolving the basic idea into a final robust template class.
Predicates vs. Function Objects
Nicolai M. Josuttis
A function that returns a Boolean value is a predicatethat's what almost all tutorials, books, and manuals write about predicates of the standard template library (STL). However, that's not the whole story. In this article, we learn that whenever you pass a function object as a predicate to an STL algorithm, it should guarantee that it always returns the same value when invoked with the same arguments.