Hi Karl!
Many thanks for that suggestion - I adopted it for C++, and have posted my solution here for the wider world to find!
Best to all, Pete