"Handling map of files in c++" says no, one shall use std::map<std::string, std::ofstream*>
, but this leads to the new
and delete
actions, which is not so neat.
Since "Is std::ofstream movable? Yes!" and it's possible to "std::map<>::insert using non-copyable objects and uniform initialization", is it possible to handle a collection of ofstream
using std::map
? so that one won't worry about closing filestreams and delete
to release memory.
I can compromise that during using std::map<std::string, std::ofstream>
, only create, use (it to write) and close, not to copy it.