Afficher un message
Vieux 06/12/2007, 17h21   #1
johnbrown105@hotmail.com
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut ostream_iterator less useful than it could be


I think that ideally, ostream_iterator's operator=() should write the
delimiter *between*
elements and not after them.

One way of doing this:

Add a default int argument = 0 to ostream_iterator's constructor and
save the value
in a member variable counter. Then, in operator=(),

if (++counter == 1)
os << value;
else
os << delimiter << value;
}

Given that "1,2,3,4,5" is a more natural way to write a list than
"1,2,3,4,5,",
is there a particular reason why they did not do it that way?

I suppose that there should also be a method to reset the counter, or
it could be
defined that you cannot reset it, and you must instead create a new
ostream_iterator
if you want to start a new sequence.
  Réponse avec citation
 
Page generated in 0,05007 seconds with 9 queries