
3 Jul
2007
3 Jul
'07
4:48 p.m.
Ulrich Eckhardt wrote:
Too complicated still (obviously), and the not-checking/double-computation of 'done' still applies. ;)
I'd suggest this version:
while(true) { // try to read a chunk of data streamsize amt = iostreams::read(...); if(amt==-1) break; // handle data std::copy(...); total += amt; }
...which also removes the unnecessary bool 'done'.
Please note that there are two overloads of copy_impl() which contain the original while logic. The one reported has the bug, while the other one (line 102- line 122) does not. If you are going to refactor this function, then the other one should be done the same way for consistency.