|
Boost : |
From: ÇñÓîÖÛ (qbowater_at_[hidden])
Date: 2007-06-29 10:49:18
boost-1_34\boost\iostreams\copy.hpp line 80 - line 100
template<typename Source, typename Sink>
std::streamsize copy_impl( Source& src, Sink& snk,
std::streamsize buffer_size,
mpl::false_, mpl::true_ )
{ // Copy from an indirect Source to a direct Sink.
using namespace std;
typedef typename char_type_of<Source>::type char_type;
typedef pair<char_type*, char_type*> pair_type;
detail::basic_buffer<char_type> buf(buffer_size);
pair_type p = snk.output_sequence();
streamsize total = 0;
bool done = false;
while (!done) {
streamsize amt;
done = (amt = iostreams::read(src, buf.data(), buffer_size)) == -1;
std::copy(buf.data(), buf.data() + amt, p.first + total);
if (amt != -1)
total += amt;
}
return total;
}
When "iostreams::read" return -1 ,amt equal -1,it will assert in
std::copy because iterator last < first.
I use MSVC8.0 .
It crashed only in DEBUG mode.
I think it should be:
while (!done) {
streamsize amt;
done = (amt = iostreams::read(src, buf.data(), buffer_size)) == -1;
if (amt != -1){
std::copy(buf.data(), buf.data() + amt, p.first + total);
total += amt;
}
}
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk