Some code to aid in programming C++ in a functional idiom