[Boost-bugs] [Boost C++ Libraries] #5765: Container Device/Sink bug

Subject: [Boost-bugs] [Boost C++ Libraries] #5765: Container Device/Sink bug
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2011-08-09 11:49:15


#5765: Container Device/Sink bug
----------------------------------+-----------------------------------------
 Reporter: aris.basic@… | Owner: turkanis
     Type: Bugs | Status: new
Milestone: To Be Determined | Component: iostreams
  Version: Boost 1.47.0 | Severity: Problem
 Keywords: |
----------------------------------+-----------------------------------------
 i think write should be like this, otherwise if one seeks back (after
 writing to overwrite replace some data, number of bytes seeked back will
 be duplicated on the next write.
 (original line changed/replaced is commented out in code)

 {{{
 #!c++
     std::streamsize write(const char_type* s, std::streamsize n)
     {
         using namespace std;
         std::streamsize result = 0;
         if (pos_ != container_.size()) {
             std::streamsize amt =
                 static_cast<std::streamsize>(container_.size() - pos_);
             result = (min)(n, amt);
             std::copy(s, s + result, container_.begin() + pos_);
             pos_ += result;
         }
         if (result < n) {
             container_.insert(container_.end(), s + result, s + n);
             //container_.insert(container_.end(), s, s + n);
             pos_ = container_.size();
         }
         return n;
     }

 }}}

-- 
Ticket URL: <https://svn.boost.org/trac/boost/ticket/5765>
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:07 UTC