A quick experiment to see how a C++ version would shape up.