🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.sys.mac.programmer.codewarrior
Article #46

STL input iterators

#46
From: Christopher Pilsworth
Date: Tue, 16 Apr 1996 02:54
49 lines
2166 bytes
Hi there,

I am looking for someone who can help me with some STL stuff.
I have checked out a lot of the web/ftp sites for relevant code but have 
so far been unable to find any.

I bought a book the other day that showed how to use input and output 
iterators to write containers (the example was a vector) to disk.  It 
looked extremely simple.  However the compiler didn't like it.  

The method seems to work with a standard ostream or istream (cin/cout) 
but did not work when given a ifstream or ofstream as in the book.

I need this code urgently as it seems the best way to manage indexes to 
my data files and the deadline is in two weeks time.

The code in the book looked kind of like this:



ifstream myin ("infile");
ofstream myout("outfile);

istream_iterator<char> input_iter(myin), eos;
ostream_iterator<char> output_iter(myout);

vector<char> myvector ...etc. etc.
... 
(This is probably wrong but is there just to give the jist)

The problem was on the third line of code. The error message was "illegal 
template arguments".  I have checked over and over that the text was 
identical to that of the book, but still no joy!

Does the STL supplied with the Metrowerks Codewarrior 8 not like fstreams 
as arguments to this template.

I'm sorry that I can not supply my code as I am in university and the 
code is at home.  Any hints on making containers persistent (any way) 
would be very gratefully recieved.

thankyou in advance

regards

Christopher Pilsworth
HCM94CP@dmu.ac.uk
PS: Please could replies be CC'd to the above e-mail address as I 
sometimes have problems with my news reader. Thanks
Technical Details
Message-ID: <31730BFD.12E@dmu.ac.uk>
Path: arc1-ca.pugleaf.net!yama.mcc.ac.uk!dmu!usenet

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!yama.mcc.ac.uk!dmu!usenet
From: Christopher Pilsworth <hcm94cp@dmu.ac.uk>
Newsgroups: comp.sys.mac.programmer.codewarrior,comp.lang.c++,dmu.lang.c++
Subject: STL input iterators
Date: Mon, 15 Apr 1996 19:54:53 -0700
Organization: DeMontfort University
Message-ID: <31730BFD.12E@dmu.ac.uk>
NNTP-Posting-Host: mkcsug17.mk.dmu.ac.uk
Mime-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
X-Mailer: Mozilla 2.0 (Win16; I)
CC: hcm94cp@dmu.ac.uk