17 std::istream&
appendline(std::istream& is, std::string& str,
char delim) {
18 size_t size = str.size();
19 size_t capacity = str.capacity();
20 std::streamsize rest = capacity - size;
24 capacity = std::max(static_cast<size_t>(8), capacity * 2);
25 rest = capacity - size;
32 is.getline(const_cast<char*>(str.data()) + size, rest, delim);
35 size_t new_size = size + is.gcount();
40 if (is.gcount() + 1 == rest) {
43 str.reserve(capacity * 2);
std::istream & appendline(std::istream &is, std::string &str, char delim)
like std::getline(istream, string, delim) except that it appends to the string, possibly reusing buff...