Extract example into a C++ file, so that it can be tested, unfortunately this means that it no longer links to the reference documentation.