"Integration of the Standard Template Library and the Microsoft Foundation Class" - читать интересную книгу автора (Wolfgang Paul, Song Yang)

2.4.4.1 CArchive_output_iterator

Adapting the output_iterator to become the CArchive_output_iterator is very straightforward. Merely replace ostream with CArchive. The result is as follows:

template ‹class T›

class CArchive_output_iterator: public  std::iterator‹std::output_iterator_ tag, void, void› {

protected:

 CArchive* archive;

public:

 CArchive_output_iterator(CArchiveamp; s): archive(amp;s) {}

 CArchive_output_iterator‹T›amp; operator=(const Tamp; value) {

  *archive ‹‹ value;

  return *this;

 }

 CArchive_output_iterator‹T›amp; operator*() {return *this;}

 CArchive_output_iterator‹T›amp; operator++() {return *this;}

 CArchive_output_iterator‹T›amp; operator++(int) {return *this;}

};