[Boost-bugs] [Boost C++ Libraries] #4728: "iostreams::detail::mode_adapter<>" is never "flushable": flushing a filtering_ostream will not flush the "std::ostream" target --- patch included.

Subject: [Boost-bugs] [Boost C++ Libraries] #4728: "iostreams::detail::mode_adapter<>" is never "flushable": flushing a filtering_ostream will not flush the "std::ostream" target --- patch included.
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2010-10-12 21:52:25


#4728: "iostreams::detail::mode_adapter<>" is never "flushable": flushing a
filtering_ostream will not flush the "std::ostream" target --- patch
included.
--------------------------------------------------------------+-------------
 Reporter: Duncan Exon Smith <duncanphilipnorman@…> | Owner: turkanis
     Type: Bugs | Status: new
Milestone: To Be Determined | Component: iostreams
  Version: Boost 1.44.0 | Severity: Problem
 Keywords: |
--------------------------------------------------------------+-------------
 I have found a problem with Boost.Iostreams.
  * I'm using Boost v1.43.0 on Gentoo Linux with `gcc-4.3.4`.
   * I've reproduced it with `gcc-4.4.3`.
   * I've reproduced it with Boost v1.44.0 (from the website tarball).
   * Let me know if you need to know anything else about my environment.
  * A simple testcases attached at
 [attachment:boost_iostreams_filtering_std_ostream.cpp].
  * A patch to fix the problem is attached at [attachment:boost_iostreams-
 mode_adaptor-flushable.patch].
  * This is a different problem from #4590.

 === Details ===

 I'm going to use `io` as a synonym for the `boost::iostreams` namespace.

 I have come across a problem with `io::detail::mode_adapter<Mode, T>`,
 where `T` is a `std::ostream` or a `std::streambuf`. I came across the
 problem in `io::filtering_ostream`, but perhaps this class is used
 elsewhere also.
  * `io::detail::mode_adapter<>::category` is not convertible to any of
 `io::flushable_tag`, `io::ostream_tag`, or `io::streambuf_tag`.
  * `io::flush()` will use
 `io::detail::flush_device_impl<io::any_tag>::flush()` for `mode_adapter<,
 T>` even when `T::catagory` is convertible `flushable_tag`, `ostream_tag`
 or `streambuf_tag`.
  * As a result, `io::filtering_ostream` will not flush correctly when the
 device at the end of the chain is a non-boost `std::ostream` or a
 `std::streambuf`.
    * I expect, also, that any filters in the chain that inherit from
 `flushable_tag` also do not get flushed correctly.
  * In particular the following methods from the STL `std::ostream`
 interface will ''not'' flush the stream to the device:
  {{{
 #!cpp
 std::ostream stream(&someBuffer);

 io::filtering_ostream out;
 out.push(stream);

 // These STL methods of flushing a stream will NOT flush "stream".
 out << std::endl;
 out.flush();
 }}}
  * My solution is to have `mode_adapter<>::category` inherit from
 `flushable_tag` when appropriate, and to implement `::flush()` methods:
  {{{
 #!cpp
 }}}

-- 
Ticket URL: <https://svn.boost.org/trac/boost/ticket/4728>
Boost C++ Libraries <http://www.boost.org/>
Boost provides free peer-reviewed portable C++ source libraries.

This archive was generated by hypermail 2.1.7 : 2017-02-16 18:50:04 UTC