std::ifstream::get
has as one of its signatures
istream& get (char* s, streamsize n, char delim);
Should I use file.eof()
as a 'delimiter' for the whole file in
const std::string_view arg1{argv[1]}; // not a copy
std::ifstream file (arg1.data() ,std::ios::in|std::ios::ate);
if (file) {
auto file_size = file.tellg(); // get file size
std::unique_ptr<char[]> buf(new char[file_size]{} );
file.seekg(0); // go to beg of file
file.get(buf.get(), file_size, file.eof());
std::string_view sv{buf.get()}; // does not copy
}
The code works fine with no error, and no leaks,
but "looks suss" to use file.eof()
in this way.