🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: comp.sys.mac.programmer.codewarrior
3 messages
3 total messages Started by Christopher Pilsworth Tue, 16 Apr 1996 02:54
STL input iterators
#46
Author: 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
Re: STL input iterators
#47
Author: David Riedel
Date: Tue, 16 Apr 1996 23:07
68 lines
2799 bytes
Christopher Pilsworth wrote:
> 
> 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



Chris,

The MW compiler does not yet support default template arguments.

You need to code something like this:

istream_iterator<InputRecord, ptrdiff_t> inputFile_itor(inputFile);

where ptrdiff_t is a type. MW already knows about ptrdiff_t so just code 
it as is.  The argument to the constructor is of course the stream you 
are iterating on.

Hope this helps.

Dave Riedel
Silk City Software Inc.
Re: STL input iterators
#48
Author: Paul Kenneth Egell-johnsen
Date: Wed, 17 Apr 1996 18:20
24 lines
1086 bytes
David Riedel wrote:

[...]

> Chris,
> 
> The MW compiler does not yet support default template arguments.

As an aside. Do you (or anybody else) know if a compiler
compatible with AT&T 3.0 does support default template
arguments?

Also does that compiler support RTTI?

[...]

> Dave Riedel
> Silk City Software Inc.

-- 
Paul K Egell-Johnsen,

mailto:paulken4@afrodite.kih.no
http://afrodite.kih.no:8001/studenter/paulken4/frames/
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads