Should I be using STL?

Started by
12 comments, last by gimp 23 years, 10 months ago
                #include <iostream>#include <fstream>int main( int argc, char **argv ){	if( argc < 2 )	{		std::cout << "specify filename.  i.e.  fileTest.exe somefile" << std::endl;		return 1;	}	std::ifstream	inFile( *(++argv), std::ios::in / std::ios::out ); // The / is suppose to be an 'or' operator	std:: cout << inFile.rdbuf();	return 0;}                


Hopefully that's a start.


YAP YFIO,
deadlinegrunt

Edited by - deadlinegrunt on June 25, 2000 10:00:10 PM

Edited by - deadlinegrunt on June 25, 2000 10:00:31 PM

Edited by - deadlinegrunt on June 25, 2000 10:01:22 PM

~deadlinegrunt

Advertisement
Thanks it IS a start. The code needed to make STL ''do stuff'' seems a lot different to the way I code classes, perhaps thats a lesson in itself, but for now I''m just trying to make sence of it all...


In the interim I''ve been playing with map::. It looks like a nice place to hold my keyboard bindings... this might not seem so bad after all...


Thanks again...
Chris Brodie
IMPORTANT NOTE:

The original poster seemed to insinuate that STL was suggested as a way to make things thread-safe.

STL is not thread-safe.

If you want to make it thread-safe, you must handle synchronization externally.

On another note, it seems that about 10-20% of the questions on this board are starting to be about STL. Maybe there should be a separate discussion group for it?
Stoffel, small comment on your post about thread-safety: first of all, technically, STL says nothing about thread-safety. An implementation does. The STL implementation from SGI (on the page that deadlinegrunt mentions, is thread safe. For a discussion, see http://www.sgi.com/Technology/STL/thread_safety.html. SGI's implementation is exception-safe as well.

Another popular (free) STL implementation is STLport (see http://www.stlport.org). Since it's based on SGI's code, it's thread safe as well. It includes the new SGI IOstreams library as well.

Other implementations (like the one that comes with VC++ 6) might not be thread safe. The best way to find out is to check the documentation that comes with it.

Erik

Edited by - Erik Post on June 26, 2000 3:23:19 PM

This topic is closed to new replies.

Advertisement