From 0d2ac93f4a3bec9d2fe2719b270333193d20596b Mon Sep 17 00:00:00 2001 From: Stephan Bergmann Date: Sun, 16 Dec 2018 12:52:56 +0100 Subject: Fix o3tl::string_view streaming operator << (The unnecessary os.setstate(std::ios_base::failbit) was due to a misreading of C++17 [ostream.formatted.reqmts]/1.) Change-Id: I7d8285230cb316c7af45c76029e9629517d05d56 Reviewed-on: https://gerrit.libreoffice.org/65217 Tested-by: Jenkins Reviewed-by: Stephan Bergmann --- include/o3tl/string_view.hxx | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) (limited to 'include/o3tl') diff --git a/include/o3tl/string_view.hxx b/include/o3tl/string_view.hxx index b605da65ac90..2bc182034342 100644 --- a/include/o3tl/string_view.hxx +++ b/include/o3tl/string_view.hxx @@ -732,12 +732,13 @@ operator <<( std::basic_ostream & os, basic_string_view str) { - typename std::basic_ostream::sentry sentry; + typename std::basic_ostream::sentry sentry(os); if (sentry) { auto const w = os.width(); - auto const pad - = std::max::type>( - w < 0 ? 0 : w, str.size()); + auto pad + = std::max::type>( + w < 0 ? 0 : w, str.size()) + - str.size(); auto const after = (os.flags() & std::ios_base::adjustfield) == std::ios_base::left; if (pad != 0 && !after) { @@ -754,8 +755,6 @@ operator <<( } } os.width(0); - } else { - os.setstate(std::ios_base::failbit); } return os; } -- cgit