irritating corner-case c++ question
Feb. 29th, 2008 03:19 amIs there any portable way to read [as in the system call] from a file directly into a C++ standard string? One would like to do something like
str.reserve(filesize); got = ::read(fd, str.data(), str.capacity()); str.enlarge_to_cover(got);
(error handling and loop until EOF omitted for clarity) but I can't actually find a method that does enlarge_to_cover(). Also, data() returns a read-only pointer.
... why am I still awake?