Using stateful functors

For another example posts on functors (function objects) see here. A functor is an instance of a C++ class that has the operator() defined. One big advantage of functors is that when you define the operator() in C++ classes you not only get objects that can act like functions, but can also store state as …

Continue reading ‘Using stateful functors’ »

Using boost::bind to assign functions

Some code samples I have collated in the sample below, that demonstrate how boost::function can be assigned with functors, ordinary functions, class member functions and overloaded class member functions respectively. Giving the following output: 5 / 3 = 1.66667 Average = 37 Average = 37 Average = 37 Do this Do that Do other Integer …

Continue reading ‘Using boost::bind to assign functions’ »

Getting started with the Boost libraries in Cygwin

This post assumes that the boost libraries have been downloaded and extracted to the directory of your choice. See this previous posting for more details on how to download and extract the Boost libraries. Open Cygwin and cd to the location where your Boost libraries have been installed. For Windows directories with white spaces please …

Continue reading ‘Getting started with the Boost libraries in Cygwin’ »

Using boost::bind as an improved means of calling member functions

This post takes a look at using boost::bind as a means of calling class member functions in an efficient and generic way. It basically summarizes what has already been said at Björn Karlsson’s excellent Informit article. Since I found the post useful, I thought it worth reproducing here, using the same status class but containing …

Continue reading ‘Using boost::bind as an improved means of calling member functions’ »