My plan is to build a fileContainer
that consists mainly of a std::map
that associate specific file
s to an ID
. Each file
has for attributes a ofstream
, a path (string
) and a few other information.
The problem is that an ofstream
cannot be copied (Why copying stringstream is not allowed?) and cannot even be moved (Why can't std::ostream be moved?). One can therefore not create file
objects to then insert
them into the map of the fileContainer
.
What I am trying to do is something like
file f(arguments...); // create a `file`
FC.insert(f); // Note the FC is a global singleton of class `fileContainer`
...
{
file& f = FC.getFile(fileID); // find a specific file in the file container
f.open();
f.write(s1);
f.write(s2);
f.write(s3);
f.close();
}
I fail to see how such functionality could be achieved without having to copy or move a stream
. Can you help me out to build this type of functionality?
Aucun commentaire:
Enregistrer un commentaire