Oh, just saw that you were looking for a Cpp solution.