summaryrefslogtreecommitdiffstats
path: root/include/o3tl
diff options
context:
space:
mode:
authorStephan Bergmann <sbergman@redhat.com>2018-12-16 12:52:56 +0100
committerStephan Bergmann <sbergman@redhat.com>2018-12-16 17:14:33 +0100
commit0d2ac93f4a3bec9d2fe2719b270333193d20596b (patch)
tree4c3e68d3c708c03b24f4e20181f2d6bd631399f4 /include/o3tl
parenttdf#119217 Deleting of unnecessary empty space in Document in use dialog (diff)
downloadcore-0d2ac93f4a3bec9d2fe2719b270333193d20596b.tar.gz
core-0d2ac93f4a3bec9d2fe2719b270333193d20596b.zip
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 <sbergman@redhat.com>
Diffstat (limited to 'include/o3tl')
-rw-r--r--include/o3tl/string_view.hxx11
1 files changed, 5 insertions, 6 deletions
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<charT, traits> & os,
basic_string_view<charT, traits> str)
{
- typename std::basic_ostream<charT, traits>::sentry sentry;
+ typename std::basic_ostream<charT, traits>::sentry sentry(os);
if (sentry) {
auto const w = os.width();
- auto const pad
- = std::max<std::make_unsigned<decltype(w + str.size())>::type>(
- w < 0 ? 0 : w, str.size());
+ auto pad
+ = std::max<typename std::make_unsigned<decltype(w + str.size())>::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;
}