When you do that kind of stuff, keep in mind that many programs modify files by writing to a temp file and then renaming that file.
On a secondary note, "modern C++" needs to be stopped. This is absurd:
std::chrono::duration<int, std::milli>
Just say no. Don't include stuff like <chrono> or <functional>. Ignore Bjarne's opinions. Don't read books by Scott Meyers. Being effective with C++ means understanding its "powers" and then not using them.