From 7e51fde0bccc378fcdc075e20583af03201aecfe Mon Sep 17 00:00:00 2001 From: Jonathan Turkanis Date: Wed, 6 Apr 2005 23:00:01 +0000 Subject: [PATCH] corrections to flush [SVN r28032] --- include/boost/iostreams/operations.hpp | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/include/boost/iostreams/operations.hpp b/include/boost/iostreams/operations.hpp index fbdc9ba..c28efd4 100755 --- a/include/boost/iostreams/operations.hpp +++ b/include/boost/iostreams/operations.hpp @@ -446,9 +446,17 @@ struct close_impl template<> struct close_impl { template - static void close(T&, BOOST_IOS::openmode) { } + static void close(T& t, BOOST_IOS::openmode which) + { + if ((which & BOOST_IOS::out) != 0) + iostreams::flush(t); + } template - static void close(T&, Sink&, BOOST_IOS::openmode) { } + static void close(T& t, Sink& snk, BOOST_IOS::openmode which) + { + if ((which & BOOST_IOS::out) != 0) + iostreams::flush(t, snk); + } }; #include // Borland. @@ -504,18 +512,14 @@ template<> struct flush_device_impl { template static bool flush(T& t) - { - bool result; - if (!(result = t.flush())) - t.clear(); - return result; - } + { return t.rdbuf()->BOOST_IOSTREAMS_PUBSYNC() == 0; } }; template<> struct flush_device_impl { template - static bool flush(T& t) { return t.BOOST_IOSTREAMS_PUBSYNC(); } + static bool flush(T& t) + { return t.BOOST_IOSTREAMS_PUBSYNC() == 0; } }; template<> @@ -527,10 +531,10 @@ struct flush_device_impl { template<> struct flush_device_impl { template - static bool flush(T& t) { return false; } + static bool flush(T& t) { return true; } }; -//------------------Definition of flush_impl----------------------------------// +//------------------Definition of flush_filter_impl---------------------------// template struct flush_filter_impl