Instructor-led training
C++ Standard Template Library Training in Kings Mountain, North Carolina
The C++ Standard Template Library is a large part of the C++ Standard Library.
What you'll learn
Private Training for Teams
This course is offered as private, instructor-led training for organizations, onsite in Kings Mountain, North Carolina or live online. Dates, delivery format, and course content are arranged around your team's requirements.
This course is not currently scheduled as a public class for individual enrollment.
Request Group TrainingPrerequisites
Course Outline
An Overview of Templates
Templates
Overloading functions
Template functions
Specializing a template function
Disambiguation under specialization
Template classes
An array template class
Instantiating a template class object
Rules for templates
Non member function with a template argument
Friends of template classes
Templates with multiple type parameters
Non type parameters for template classes
Comments regarding templates
Overview of the Standard Template Library
Perspective
History and evolution
New features in C++
The Standard Template Library
Design goals
Header files
STL components
Containers
Algorithms
Iterators
Examples from STL
Example: vectors, lists
Example: maps
Example: sets
Example: multiset
Example: find with a vector
Example: find with a list
Example: merge
Iterators
Function objects
Adaptors
STL Containers
Vector
Deque
List
The beauty of STL
Associative Containers
Set
Multiset
Map
Multimap
STL Iterators
Input iterators
Output iterators
Forward iterators
Backward iterators
Function Objects
Function objects vs. function pointers
Predicate function objects
Comparison function objects
Numeric function objects
Programmer supplied function objects
Built-in function objects
STL Algorithms
Non-Mutating sequence algorithms
Mutating sequence algorithms
Sorting and searching algorithms
Numeric algorithms
General
Container Adaptors
Wrapper classes
Stack container adaptors
Queue container adaptors
Priority_Queue container adaptors
Allocators
Rationale
Default Allocator
Custom Allocators
Container Storage Allocation
What makes the STL hard to master
The STL's three parts (containers, algorithms and iterators) are designed to work together. The difficulty is less in any one class than in seeing why the pieces fit and which combination to pick.
- Templates come first. The syllabus opens with template functions, specialization and disambiguation, template classes, friends of template classes, multiple type parameters and non-type parameters. Template-heavy code produces long compiler diagnostics, so shaky template fundamentals make the rest of the course harder.
- Iterators are not just pointers. They generalize pointers and link algorithms to containers. The syllabus separates input, output, forward and backward iterators. Which category a container offers determines which algorithms can run on it.
- Container choice is a design decision. Vector, deque and list have different traversal and modification characteristics. The associative containers (set, multiset, map, multimap) bring ordering and key-based lookup. A common misconception is that one container fits every case.
- Behavior is supplied by function objects. Algorithms take predicates, comparison objects and numeric function objects, either built in or programmer-supplied. The syllabus compares them with function pointers, which explains why they are used so widely.
- Adaptors and allocators are layers over the core. Stack, queue and priority_queue are built on lower-level containers, and allocators encapsulate memory-model information, including default and custom allocators. Both make more sense once the containers are familiar.
The course builds in that order: templates, a survey and tour of STL examples, containers, iterators, function objects, algorithms, adaptors, then allocators.
Who it suits and what to take around it
The course is a general-level, three-day class for programmers who already write C++ and want to use the standard containers and algorithms fluently instead of hand-writing data structures and loops. It also suits maintainers who need to read STL-heavy code. The listed prerequisite is C++ Programming. The C++ Programming course is the natural foundation, since classes, operator overloading and basic template syntax are assumed. The template overview can be covered briefly for experienced students or thoroughly for those who need it.
For next steps, the C++11/C++14 course suits teams whose code uses newer language features. The Advanced C++ for Experts course suits developers who want to continue into design patterns and further STL topics at an advanced level. Organizations that work with a particular compiler or language standard can request a training proposal to discuss private training tailored to the versions they use.
Illustrative scenarios
The scenarios below are illustrations of how the course material can be applied. They are not descriptions of specific organizations or of the course's lab exercises.
- Replacing hand-written data structures. A team might maintain a codebase with its own linked lists and sorting loops. Knowing vector, list and deque, plus the sorting, searching and mutating sequence algorithms, lets them replace that code with standard components and reason about the trade-offs.
- Keyed lookup with custom ordering. A developer might need records indexed by an identifier, or a set ordered by a business rule. Map, multimap, set and multiset cover the containers, and a programmer-supplied comparison function object defines the ordering.
- Task scheduling and memory control. A team might build a work queue on priority_queue, a container adaptor. If allocation behavior matters, as in a memory-constrained component, the allocator material (default allocator, custom allocators, container storage allocation) explains where to intervene.
AI coding assistants and the STL
AI coding assistants can help with several STL tasks. They can explain a long template error message, suggest an algorithm in place of a raw loop, and draft a predicate or comparison function object. They can also draft unit tests for container-based code.
They tend to fail where the STL's rules are subtle:
- Choosing a container that compiles but has the wrong performance characteristics for the access pattern.
- Writing a comparison function object for a set, map or sort that does not define a consistent ordering.
- Using an iterator after the container has been modified, or misusing mutating algorithms such as removal, which rearrange elements without shrinking the container.
- Producing custom allocators that look plausible but break container requirements.
To verify, review generated code against what you know of the iterator category each algorithm requires and the container's behavior. Build with strict warnings, run tests that exercise insert and erase paths, and use sanitizers and static analysis to catch memory errors and undefined behavior that only appear in optimized builds.
Frequently asked questions
What level is this course and what should I know first?
It is a general-level, three-day course. The listed prerequisite is C++ Programming, so you should be comfortable writing C++ classes. The opening template overview can be a quick review or a thorough introduction, depending on the group.
What does the course cover?
Templates, an orientation to the STL and a tour of examples, then containers (vector, deque, list, set, multiset, map, multimap), iterators, function objects, algorithms, container adaptors (stack, queue, priority_queue) and allocators.
Can the course be delivered privately for our team, onsite or online?
Yes. HSG provides private training for organizations, delivered onsite at the client's location or live online.
Can the content be customized?
Private training can be customized, including tailoring to the technology versions your organization uses. You can describe your needs through a training proposal request.
Training locations
C++ Standard Template Library training across the U.S. and beyond.
We provide private C++ Standard Template Library training for organizations, onsite at your location or live online, throughout the United States and internationally.
View all C++ Standard Template Library training locations
Train your team with HSG
Private, instructor-led training customized for your organization.
- Onsite or live online delivery
- Customized curriculum
- For a single employee or an entire team
- Flexible scheduling
- Experienced instructors
Questions? Call us at 303.377.6176
or email info@hartmannsoftware.com
Ready to train your team?
Let's customize this training for your organization.
Tell us about your employees, your goals, and your preferred schedule. We'll prepare a training proposal covering scope, delivery format, and pricing.