Date: Sun, 5 Nov 2023 20:37:09 +0100
Hello,
This question may be old and probably has already been answered before, but
I cannot find any references. Was there ever considered adding to the
standard a simple text file manipulation API (better performing and less
cumbersome to use than std::fstream)? Read/write file from/to std::string
is a common operation and whenever I need to write a piece of code like
that it does not look nice plus there is a dispute about std::fstream
performance penalty when compared to C-style fopen/fclose. I would like to
have an API (possibly new overloads like below):
std::string fread(const std::filesystem::path& infile);
size_t fwrite(const std::filesystem::path& outfile, const std::string&
outstr);
I am probably oversimplifying (there should probably be some extra
parameters, defaulting to something most useful), but this is just to
better show what I have in mind.
Thanks,
Greg
This question may be old and probably has already been answered before, but
I cannot find any references. Was there ever considered adding to the
standard a simple text file manipulation API (better performing and less
cumbersome to use than std::fstream)? Read/write file from/to std::string
is a common operation and whenever I need to write a piece of code like
that it does not look nice plus there is a dispute about std::fstream
performance penalty when compared to C-style fopen/fclose. I would like to
have an API (possibly new overloads like below):
std::string fread(const std::filesystem::path& infile);
size_t fwrite(const std::filesystem::path& outfile, const std::string&
outstr);
I am probably oversimplifying (there should probably be some extra
parameters, defaulting to something most useful), but this is just to
better show what I have in mind.
Thanks,
Greg
Received on 2023-11-05 19:37:22