andrew-d/cpplog

ostrstream deprecated

eigenbom opened this issue · 5 comments

hi, i believe ostrstream is deprecated. well at least i keep getting annoying warnings about it being deprecated. here's a quick update:

a fix: cpplog.h
9: -> #include
180: -> std::ostringstream stream;
304: -> char lastChar = m_logData->buffer[m_logData->stream.str().size() - 1];

cheers!

oh whoops, that seemed to have broken it ... i will revert my changes and ignore the warnings for now.

Yeah, ostrstream is deprecated according to the standard - but as far as I can tell, there's no "official" replacement with the same features. On my todo list is to write a replacement class that mimics the same functionality.

I don't know about this stream/buffer stuff ... but why can't u just use ostringstream?

In short, because of speed. ostrstream allows you to specify the buffer to write to, whereas ostringstream manages its own buffer and requires additional copying - i.e the .str() method returns a copy, which is substantially less efficient.

Since a logging library might be called in a tight loop with speed requirements, I find that using ostringstream is too slow.

Ah right, no worries!