From d09b37d3ef8e978d214abcc819937abd33d18059 Mon Sep 17 00:00:00 2001 From: Andrey Semashev Date: Sun, 2 Jun 2013 19:16:50 +0000 Subject: [PATCH] More modifications according to the review. [SVN r84611] --- include/boost/utility/string_ref.hpp | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/include/boost/utility/string_ref.hpp b/include/boost/utility/string_ref.hpp index febdabe..235ac50 100644 --- a/include/boost/utility/string_ref.hpp +++ b/include/boost/utility/string_ref.hpp @@ -406,11 +406,11 @@ namespace boost { template inline void insert_fill_chars(std::basic_ostream& os, std::size_t n) { - charT fill_chars[8]; - std::fill_n(fill_chars, 8, os.fill()); - for (std::size_t m = n / 8u; m > 0 && os.good(); --m) - os.write(fill_chars, 8); - n &= 7u; + enum { chunk_size = 8 }; + charT fill_chars[chunk_size]; + std::fill_n(fill_chars, static_cast< std::size_t >(chunk_size), os.fill()); + for (; n >= chunk_size && os.good(); n -= chunk_size) + os.write(fill_chars, static_cast< std::streamsize >(chunk_size)); if (n > 0 && os.good()) os.write(fill_chars, static_cast< std::streamsize >(n)); } @@ -427,7 +427,8 @@ namespace boost { } else { os.write(str.data(), static_cast< std::streamsize >(size)); - detail::insert_fill_chars(os, alignment_size); + if (os.good()) + detail::insert_fill_chars(os, alignment_size); } }