You don't have to be a C++ expert to use STL. The World Wide Web is a great place to find tools, tutorials, and moral support.
Focus on STL
The WWW has historically been one of the most informative sources of information about leading-edge programming technologies. Though STL has been around for a few years now, it has only recently made its way out of computer science labs and into the toolkits of corporate application developers. My quick survey of WWW via the AltaVista search engine yielded more than 1,000 documents. After considerable weeding, I'm happy to share with you some of the more relevant pages in several subcategories: tutorials, vendor-specific pages, and pointer-pages:
STL Tutorials
Jak Kirman <[email protected]> of the CS faculty at Brown University has thrown together what he considers "a very modest tutorial" on STL. You can read it as a hypertext document or print it out in Postscript for offline perusal. Kirman motivates the discussion with a look at the STL sort template while introducing each of the five categories of STL components one at a time. Other sections address the philosophy of STL and suggest how to extend STL to meet your own needs. Kirman makes good use of graphical figures to illustrate his points. Check it out for yourself at:
<IMG HEIGHT="30" WIDTH="24" src="http://twimgs.com/ddj/cuj/images/cuj9609volkman/volkman1.gif">http://www.cs.brown.edu/people/jak/programming/stl-tutorial/tutorial.html
Mumit Khan <[email protected]> at the Center for X-Ray Lithography at the University of Wisconsin provides an exhaustive amount of advice and coding examples (163Kb) in his "STL Newbie Guide." Major headings include: Writing Container Objects, Pointers and STL, STL Iterators, Persistent STL, and a new section about Predicates, Comparators, and General Functions. In addition to how-to information, he specifically addresses common pitfalls, such as "Gotchas with Storing Pointers to Objects." Its all at:
<IMG HEIGHT="30" WIDTH="24" src="http://twimgs.com/ddj/cuj/images/cuj9609volkman/volkman2.gif">http://www.xraylith.wisc.edu/~khan/software/stl/STL.newbie.html#class_howto
David R. Musser <[email protected]> has collected some introductory information, example applications that use STL, and pointers to other STL reference sources. Specifically, Musser's "Standard Template Library" page includes example source code for demonstrating STL vectors and vector iterators, an anagram checking application, and searching and sorting user-defined records. More advanced users may want to look at the official ANSI/ISO STL specifications (available in Postscript form) there.
<IMG HEIGHT="30" WIDTH="24" src="http://twimgs.com/ddj/cuj/images/cuj9609volkman/volkman3.gif">http://www.cs.rpi.edu/~musser/stl.html
David R. Musser and Atul Saini, authors of STL Tutorial and Reference Guide: C++ Programming with the Standard Template Library [see a review of this book elsewhere in this issue - mb] offer a set of source code resources specific to their book. More than 70 example programs are available and you can browse selected parts of the book. Certainly, the website will belp you decide whether Musser and Saini's book would be appropriate for you.
<IMG HEIGHT="32" WIDTH="31" src="http://twimgs.com/ddj/cuj/images/cuj9609volkman/volkman4.gif">http://www.aw.com/cp/musser-saini-source.html
STL Vendor Specifics
G. Bowden Wise <[email protected]>, of the CS faculty at Rensselaer Polytechnic Institute, has published a pragmatic set of notes entitled "Using the The Standard Template Library with Borland C++." In this document, he describes how to make STL work properly with Borland C++ 4.5 and optionally with Borland's Object Windows Library (OWL). Specifically, he details required changes to algobase.h, funtion.h, defalloc.h and other header files. Also appearing are detailed explanations of the known warnings that the Borland compiler emits while processing STL. You can read about it at:
<IMG HEIGHT="30" WIDTH="24" src="http://twimgs.com/ddj/cuj/images/cuj9609volkman/volkman5.gif">http://www.cs.rpi.edu/~wiseb/stl-borland.html
or download Wise's patched STL files directly at:
<IMG HEIGHT="32" WIDTH="31" src="http://twimgs.com/ddj/cuj/images/cuj9609volkman/volkman6.gif">http://www.cs.rpi.edu/~wiseb/stl/stlexp.zip
Microsoft's "MFC and Standard Template Library (STL) Alert" page provides a blistering disclaimer in which it places sole responsibility for STL back on Hewlett-Packard (who originally made STL freely available, but retained the copyright). Furthermore, it goes on to say that Microsoft Product Support Services will not assist in technical support issues on STL. Nevertheless, it does highlight required changes to header files (involving namespaces) that you can make yourself to achieve compatability with the Windows SDK or Microsoft Foundation Classes (MFC) and STL. Visit them at:
<IMG HEIGHT="30" WIDTH="24" src="http://twimgs.com/ddj/cuj/images/cuj9609volkman/volkman7.gif">http://www.microsoft.com/visualc/v4/v4tech/stlchg.htm
Warren Young <[email protected]> publishes the "STL Resource List," an extensive online catalog of pointers to pages detailing the STL support of C++ compilers. It also contains pointers to FTP sites where you can download a specially-tweaked version of the STL files for your specific compiler. Among the STL vendors cited are:
- Symantec C++ 7.x for Windows and 8.x for Macintosh
- Metrowerks C++ 7.0 (for Macintosh)
- Watcom C++ 10.0
- GNU C++ 2.7.1 and 2.7.2
- Rogue Wave's tools.h++ (enhanced version of STL)
- ObjectSpace's STL <Toolkit> (a multi-platform STL)
<IMG HEIGHT="32" WIDTH="32" src="http://twimgs.com/ddj/cuj/images/cuj9609volkman/volkman8.gif">http://www.cyberport.com/~tangent/programming/stlres.html
STL Pointer Pages
Here's some "pointers to pointers." These pages provide a rich set of jumping-off points for your own exploration of STL:
<IMG HEIGHT="32" WIDTH="32" src="http://twimgs.com/ddj/cuj/images/cuj9609volkman/volkman9.gif">http://www.cs.rpi.edu/~wiseb/stl-notes.html
http://www.xraylith.wisc.edu/~khan/software/stl/STL.newbie.html#resources
http://cs.ucr.edu/~jcharvat/stl.html
STL Usenet Newsgroup Resources
Usenet newsgroups provide an ongoing discussion about the pros and cons of STL implementations. Jan Charvat, a graduate student in Computer Science at the University of California (Riverside), recommends the following newsgroups for STL coverage:
- comp.std.c++
- comp.lang.c++
- comp.lang.c++.moderated
Before posting to Usenet, make sure you've read the STL FAQ, available at:
<IMG HEIGHT="30" WIDTH="24" src="http://twimgs.com/ddj/cuj/images/cuj9609volkman/volkma10.gif">ftp://butler.hpl.hp.com/stl/stl.faq
Reader Suggested Links
Paulo Eduardo Neves <[email protected]> at Laboratorio de Metodos Formais in Rio de Janeiro, Brazil submits his favorite set of C/C++ links. As usual, I'll provide a brief description of each.
The Code Economics project (CodEc) provides a useful set of links to freeware linear algebra (matrices) and numerical analysis tools for C/C++. It also hosts the source and documentation for Chris Burchenhall's MatClass and Robert Davies NewMat08. The MatClass C++ matrix class library includes makefiles for Borland and Microsoft C++. The NewMat08 matrix class library supports Borland, Microsoft, AT&T, Zortech, Watcom, GNU, and most other C++ platforms.
<IMG HEIGHT="32" WIDTH="63" src="http://twimgs.com/ddj/cuj/images/cuj9609volkman/volkma11.gif">http://netec.mcc.ac.uk/~adnetec/CodEc/C_Cpp.html
Custom Innovative Solutions Corporation publishes its C source code in shareware form on the web. You're free to look at and download the source code. If you find the code useful in a commercial software setting, you are asked to pay a small licensing fee. Specific categories include: CGI Tools, File Handling Utilities, Graphics, Indexing and Searching, Numeric Conversions, Parameters and Configuration, Patterns and Parsing. I was most impressed by CNVL2.C, which can convert a long integer to a printable representation in any numbering base (from base 2 to base 90).
<IMG HEIGHT="32" WIDTH="31" src="http://twimgs.com/ddj/cuj/images/cuj9609volkman/volkma12.gif">http://www.cisc.com/src/c/main.html
The online hypertext version of the GNU C Library reference manual is very convenient to use. You have instant access at your fingertips using the three-tiered table of contents to a variety of topics. Here's just a sampling of the topics:
- Pipes and FIFOs
- Searching and sorting
- Pattern matching and shell-style word expansion
- Calendars, timezones, and alarms
- Defining and using signal handlers
- Locales, internationalization, and extended character sets
<IMG HEIGHT="30" WIDTH="24" src="http://twimgs.com/ddj/cuj/images/cuj9609volkman/volkma13.gif">http://www.ia.pw.edu.pl/tex-info/libc/libc_toc.html#SEC492
Ajay Shah <[email protected]> at the Centre for Monitoring Indian Economy, Bombay, compiles the "Free C/C++ Sources for Numerical Computation" page. As the name implies, it is an index of pointers to other types of information, including:
- Free source code available on the net
- Books which come with source code, and hence act as low-cost libraries
- Articles and documents, especially those available over the net
Unlike many other resource lists, this one specifically cites the author name, supported platforms, FTP site, and version information.
<IMG HEIGHT="32" WIDTH="32" src="http://twimgs.com/ddj/cuj/images/cuj9609volkman/volkma14.gif">http://gauge.phys.uva.nl:2001/c-sources.html
or try
<IMG HEIGHT="32" WIDTH="32" src="http://twimgs.com/ddj/cuj/images/cuj9609volkman/volkma15.gif">ftp://ftp.usc.edu:/pub/C-numanal/numcomp-free-c.gz
The "C++ Virtual Library," maintained by Lutz Lilje <[email protected]> is a website that has something for everyone from the C++ newbie to those on the bleeding edge of the C++ standards. As you might expect, such a site is primarily focused on providing useful links to authoritative sources of information. Lilje's page is one of the most active programming resources on the web and has earned the coveted "Four-Star Site" award from Magellan for his efforts. Specific areas of interest include:
- Getting Started: Documents and sources on C++ and OOP
- Learning C++: Virtual courses and tutorials
- Free Packages: Freely available C++ packages of all kinds
- Conferences: List of OOP and Computing conferences
- OOLP: Discussion on Object-Oriented Literate Programming
- Tools & Products: Descriptions of products
- General OO: Object-Oriented programming resources.
There are few sites I visit often enough to merit a bookmark, but the "C++ Virtual Library" is definitely on my hot links list.
<IMG HEIGHT="32" WIDTH="32" src="http://twimgs.com/ddj/cuj/images/cuj9609volkman/volkma16.gif">http://info.desy.de/user/projects/C++.html
If you would like to share some of your favorite C/C++ sources, please email me at [email protected].
C/C++ Mailbag
Here's a sampling of queries which have come to me recently via e-mail.
[email protected] writes:
At my work, we might be able to use a program that can analyze C source code and generate a call tree along with various programming metrics. Do you know of any shareware like that? There's commercial stuff, but it costs in the thousands. I'd like to find something more reasonably priced.
C/C++ Answer Man:
There's no need to pay a fortune for good source code analysis (how about just $47 for a great shareware program?). Try C Exploration tools for Windows. Its C Function Tree and C Structure Tree make program and data structure logic as clear as can be. As for metrics, I'll highlight only a few of them here:
- Number of source code lines for every file
- Number of included files for every source file
- For every defined function:
- Number of lines
- Number of functions called
- Number of flow control statements
- Maximum brace nesting level
- Whether it's used only in this file
- Function or data type reference list for every file
- Location of multiply defined functions and data types
- Location of all overloaded C++ functions
- #include file dependencies for every source file
- #include file tree for nested #includes
- Cross-reference for every function or data type
- Parent/child relationship for functions & data types
- C++ class inheritance tree
- C structure/union byte offset calculation
Check out volume #437 on the CUG CD-ROM or by FTP at
ftp://ftp.cdrom.com/pub/cica/win3/programr/cxtw107.zip
[email protected] writes:
I would prefer a better method of searching for information and code on the CUG CD-ROM (please bear in mind that my only exposure is the 1994 CD). A hyper-text style index with search functions is preferable.
C/C++ Answer Man:
Ask no more! The June 1996 edition of C/C++ Users Group CD-ROM includes a hypertext index of volumes 400-437, by Subject keywords, Title, Language, and Platform (OS/CPU). Whats more, you even get a free licensed version of the popular I-VIEW offline HTML viewer (http://www.talentcom.com/iview/iview.htm) to use with it. A hypertext index of CUG CD-ROM is available online at http://www.HAL9K.com/cug/.
[email protected] writes:
I am interested in simulation, especially discrete event-driven simulations.
C/C++ Answer Man:
Well, since you didn't specifically ask for C or C++, I'll assume that C++ class libraries will work for you. I have two specific packages I think you should look at: C++SIM and CNCL.
The C++SIM discrete event process based simulation package provides Simula-style class libraries. C++SIM was written by M.C. Little and D. McCue at the Department of Computing Science in the University of Newcastle upon Tyne (England). The same distribution also includes the SIMSET linked list manipulation facilities. According to MacLennan (1983), Simula was the first computer language to incorporate the ideas of "class" and "object" constructs in 1967. C++SIM currently claims usability only on Unix workstations, such as SUN Sparcs. C++SIM version 1.0 (released 06/15/92) is now available as volume #394 on the CUG CD-ROM. See also the C++SIM home page:
http://ulgham.ncl.ac.uk/C++SIM/homepage.html
The Communication Networks Class Library (CNCL) is a C++ library created by the Communication Networks department of Aachen, University of Technology, Germany. CNCL is both a class library featuring generic C++ classes as well as a simulation library with strong points in random number generation as well as statistical and event-driven simulation. CNCL v1.4 (released 01/05/96) is available on the CUG CD-ROM as volume #443. See also the CNCL home page:
http://www.comnets.rwth-aachen.de/doc/cncl.html
Victor R. Volkman received a BS in Computer Science from Michigan Technological University. He has been a frequent contributor to the C/C++ Users Journal since 1987. He is the author of the book Windows Programming with Shareware Tools. He can be reached at the HAL 9000 BBS (313)663-4173, URL http://www.HAL9K.com/home.htm, or email to [email protected].