From da5669c3dfaab09341b03448d26eb6686adfa368 Mon Sep 17 00:00:00 2001 From: Andrey Semashev Date: Sun, 26 May 2013 16:04:10 +0000 Subject: [PATCH] write() no longer asserts when the stream wrapper is not attached to a string. Rather, it behaves more like a standard stream write() when the stream is bad. [SVN r84514] --- include/boost/log/utility/formatting_ostream.hpp | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/include/boost/log/utility/formatting_ostream.hpp b/include/boost/log/utility/formatting_ostream.hpp index 00b3660..0004984 100644 --- a/include/boost/log/utility/formatting_ostream.hpp +++ b/include/boost/log/utility/formatting_ostream.hpp @@ -355,11 +355,14 @@ public: typename aux::enable_if_char_type< OtherCharT, basic_formatting_ostream& >::type write(const OtherCharT* p, std::streamsize size) { - m_stream.flush(); + sentry guard(*this); + if (guard) + { + m_stream.flush(); - string_type* storage = m_streambuf.storage(); - BOOST_ASSERT(storage != NULL); - aux::code_convert(p, static_cast< std::size_t >(size), *storage, m_stream.getloc()); + string_type* storage = m_streambuf.storage(); + aux::code_convert(p, static_cast< std::size_t >(size), *storage, m_stream.getloc()); + } return *this; }