Scott Meyers Training Courses
An Effective Introduction to the STL
The Standard Template Library (the STL) has revolutionized C++ software development. This seminar is a hard-core, hands-on, in-the-trenches indoctrination in the ways of the STL. In a combination of lectures and labs, this course brings out the underlying design of the STL, demonstrates how to take advantage of the library's strengths, and shows how to avoid its weaknesses.
Course Highlights
Participants will gain:
- An understanding of the architecture behind the STL, including its core components and concepts.
- Mastery of the subtle differences in semantics of member and non-member functions with the same name, e.g., find, remove, etc.
- Knowledge of how to integrate STL containers with code expecting arrays and other C-like data structures.
- The ability to cope with the complex STL-related error messages compilers often generate.
Each attendee will also receive a copy of Nicolai M. Josuttis' The C++ Standard Library, an excellent reference for not just the STL, but for the entire standard C++ library.
Who Should Attend
This seminar is designed for practicing C++ programmers, but the material it covers is also important for system architects, library designers, team leads, and technical managers for C++ systems that will or may take advantage of the STL. Previous exposure to the STL is not necessary, but attendees should be familiar with templates and operator overloading in C++.
Format
Lectures and programming labs.
Length
Four full days (six to seven hours per day).
Detailed Topic Outline
- Concepts and Architecture of the STL:
- Arrays and pointers, half-open ranges
- Generalizing pointers to iterators
- Generalizing arrays to sequences
- Algorithms
- Conventions and extensibility
- Function objects
- STL headers
- iterators vs. const_iterators
- Thread safety and the STL
- Exercises
- Containers I: Introduction and Sequence Containers:
- Overview of containers and container adapters
- Containers and iterator invalidation
- Universal container functionality
- vector and string
- size, capacity, "the swap trick," and "shrink to fit"
- vector operations
- Using vector with C APIs
- vector<bool>
- string functionality
- deque functionality
- list functionality
- Exercises
- Containers II: Associative Containers:
- Comparison functions
- Equality vs. equivalence
- std::pair
- Search functionality: find, count, lower_bound, upper_bound, equal_range
- Insertion and erasure
- In-place element modification
- Sorted vectors as an alternative to associative containers
- Exercises
- Iterators
- reverse_iterators and const_reverse_iterators
- Stream iterators
- C++'s most vexing parse
- Insert iterators
- Iterator categories
- Iterators vs. pointers
- Exercises
- Function Objects and Adapters:
- bind1st, bind2nd, not1, not2
- The unary_function and binary_function base classes
- ptr_fun, mem_fun, mem_fun_ref
- Overview of standard function objects (e.g., less<T>)
- Exercises
- Algorithms:
- Overview of types of algorithms
- Algorithms vs. same-named member functions
- Detailed looks at for_each, transform, remove
- Overview of searching algorithms
- Overview of reordering algorithms
- Overview of modifying algorithms
- Overview of removing algorithms
- Overview of copying algorithms
- Overview of creation algorithms
- Overview of summarizing algorithms
- Exercises
- Common STL Extensions:
- Hashed associative containers
- slist
- rope
- SGI adapters: compose1, compose2, select1st, select2nd, etc.
- Exercises
- Further Reading
For more information on this course, contact Scott directly.
