Seems to me that really the simplest solution to authors problem is to write C++ safely. I mean...this is a trivial utility app. If you can't get that right in modern C++ you should probably just not even pretend to be a C++ programmer.
Just write C++ safely! Why didn't we think of that?
Just write C++ safely! Why didn't we think of that?