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 all the examples and approaches he describes in one program. Continue reading

Printing the contents of STL containers in a generic way

A generic Print function

A way of using STL algorithms combined with template functions as a means of printing the contents of any type of STL container (eg a std::vector), containing any generic data type (eg int, std::string etc). typename T defines the generic data type held by the container, while typename InputIterator describes the STL container iterators passed to it:
Continue reading

Counting the Number of Words in a Text File in STL / C++

This post aims to illustrate the power of using STL’s associative arrays as a word counter. It reads the entire contents of the text file, word-by-word, and keeps a running total of the number of occurences of each word. All using just a few lines of code, discounting the bits that output the results.
Continue reading