Example Source Code
Scott Meyers entrusted me with the task of validating the source
code examples in his new book, Effective
STL. Since most of the examples were fragments, I wrote
the smallest test harness I could come up with for each example
and compiled them all under several popular STL platforms. Download
archive or the .tar
archive (updated January 1, 2002 to track the Effective
Here is the README.txt file directly out of the archive:
Effective STL Source Code Examples
Leor Zolman 6/22/2001
This code is being maintained by me, Leor Zolman, and NOT by
Scott Meyers. Please send all bug reports / comments / suggestions,
etc., to ME.
When Scott Meyers asked if I'd be interested in testing out the
source code for Effective STL, I jumped at the opportunity for several
- I'm relatively new to STL myself, and this was a great way
to get more experience working with the library;
- I needed test cases for my Freeware STL
Error Decryptor utility, and the error messages resulting
from typos in Scott's original code made for excellent filter
This archive is the result of that testing. For each item, I began
with a single test harness program, then added additional programs
as necessary. To make sure I was testing the exact code from the
book, I cut and pasted the actual code from an ASCII version of
the manuscript directly into the test harnesses (whitespace and
comments were reformatted to fit their new context, but that's about
The initial pass was performed under just one platform, MSVC 6
with the Dinkumware 3.08 drop-in library. After completing the test
programs and ferreting out syntax and (the rare) flagrant coding
errors, I batch-compiled all the test programs using several platforms.
The results were logged, and I annotated the logs to indicate "on
purpose" errors (intentional examples of incorrect code) as
well as errors due to the various compiler and library bugs in each
platform. The platforms and their corresponding log files are:
Microsoft VC6/Native Library
Microsoft VC6/Dinkum 3.08 Library
Borland C++ 5.5 (free cmd line)
Visual C++.NET Beta/Native Library
STLPort 4.0 Library (w/ MSVC 6)
STLPort 4.1b6 Library (w/ MSVC 6)
Main Example source files are numbered as follows:
n-1.cpp, n-2.cpp, etc.
a-1.cpp, b-1.cpp, b-2.cpp
Scott's general-purpose Container Utilities header file, ESTLUtil.h,
is included in most examples. Its "using
ESTLUtils" directive typically appears within the main()
function. The std namespace is usually pulled in within main(),
but occasionally I've put it at file scope to avoid having to splice
many std:: qualifiers into file-scope
DISCLAIMER / INVITATION FOR FEEDBACK: I completed this testing
in early April 2001, but Scott continued to tweak the book for some
time thereafter and some of the printed code examples may no longer
correspond to the test code. As discrepancies are brought to my
attention, I'll strive to bring the examples into sync with the
book. Please let me know if
you find any such discrepancies.
Bring a live, instructor-led STL on-site training to your company!
BD Software offers Advanced
C++ led by Leor Zolman, with courseware from Stephen C.
Dewhurst! Think this cannot possibly be affordable? Think
Check out BD Software's STL
Error Decryptor, a free tool to simplify STL-related error messages
under Comeau C++, Metrowerks CodeWarrior, gcc, Microsoft Visual
C++, Borland C++, Intel C++ and the EDG front end.
Need a simple, handy way to stuff arbitrary values into a new STL
container in a single statement? Check out BD Software's new, free,
STL Container Initialization Library!
Feedback (suggestions/requests, bugs, whatever) is always appreciated
-- contact firstname.lastname@example.org.
Site Map |
All text and images on this website are Copyright © 2001-2015 BD Software.
All rights reserved.