У меня есть const std::stringstream
и желание узнать, сколько байтов содержится в его базовом буфере строк.
-
Я не могу
seekg
до конца,tellg
, а затемseekg
вернуться к началу, потому что ни одна из этих операций не доступнаconst
ly. -
Я не хочу получать
str().size()
, потому чтоstr()
возвращает копию, и это может быть не тривиальное количество данных.
Есть ли у меня хорошие варианты?
(Сам поток представлен мне как const
, только потому, что он является членом другого типа, и я получаю ссылку const
на объект этого типа. Поток представляет содержимое "документа" ", его инкапсулирующий объект представляет собой ответ CGI, и я пытаюсь создать точную строку заголовка Content-Length
HTTP из operator<<(std::ostream&, const cgi_response&)
.)