Skip to product information
Learning C++ STL by Example
Learning C++ STL by Example
Description
Book Introduction
This book is a practical guide that guides you on how to effectively utilize the Standard Template Library (STL) in practice, based on the latest C++20 standard.
Beyond simple grammar explanations, it provides solutions to problems that can be encountered in actual development environments through various recipe-style examples, and accurately and systematically explains the structure and operation of STL.

It covers the core elements of STL, such as containers, algorithms, iterators, lambda expressions, and utility classes, as well as new features introduced in C++20, and also introduces advanced topics such as concurrent programming, memory management, and string processing.
This book is designed to provide practical assistance to everyone, from beginners seeking a solid foundation, to developers struggling with practical application, to experienced users seeking to master the modern C++ style. For those who have struggled to effectively utilize the STL, or those seeking to write better code based on the latest C++ standards, this book will serve as the fastest and most reliable guide.
  • You can preview some of the book's contents.
    Preview

index
Chapter 1 What's New in C++20

- Example code
- Formatting text with the new format library
- Using vectors and strings at compile time with constexpr
- Safely compare integers of different types
- Use the spaceship operator (⇔) for triple comparisons
- Easily find functional test macros using the 〈version〉 header
- Creating safer templates through concepts and constraints
- Avoid recompilation of template libraries by using modules.
- Creating a view in a container using a range

Chapter 2 General STL Functions

- Example code
- Making C arrays safe using the new span class
- Returning multiple values ​​using structured binding
- Initializing variables in if and switch statements
- Increase simplicity and clarity by using template argument inference.
- Simplify compile-time decisions using the if constexpr statement.

Chapter 3 STL Containers

- Quick overview of STL container types
- Example code
- Remove values ​​from a container using a single remove function
- Remove values ​​from an unsorted vector in constant time
- Direct and safe access to vector elements
- Maintain alignment of vector elements
- Efficiently inserting elements into the map
- Efficiently changing the keys of map items
- Using custom type keys in unordered_map
- Sort and filter user input with sets
- Creating a simple RPN calculator using deque
- Create a word frequency calculator using map
- Finding long strings as vectors of vectors
- Create a task list with multimap

Chapter 4 Compatible Iterators

- Iterator is the default
- Iterator category
- Iterator concept
- Example code
- Creating repeatable ranges
- Make iterators compatible with STL iterator properties
- Populating STL containers using iterator adapters
- Creating a generator with an iterator
- Iterate backwards using a reverse iterator adapter
- Iterate over objects of unknown length using sentinels
- Creating a zip iterator adapter
- Creating a random access iterator

Chapter 5 Lambda Expressions

- Lambda expressions
- Closer
- Example code
- Create scoped, reusable code using lambdas
- Using lambda as a description of an algorithm library
- Using std::function as a polymorphic wrapper
- Joining lambdas with recursion
- Combine the narrative into logical connections
- Calling multiple lambdas with the same input
- Creating a jump table using map-based lambdas

Chapter 6 STL Algorithms

- Example code
- Copy from one iterator to another
- Merge elements of a container into a string
- Sorting containers with std::sort
- Changing containers with std::transform
- Find items in containers
- Limiting values ​​in a container with std::clamp
- Extracting a sample from a dataset with std::sample
- Generating permutations from a series of data
- Merge sorted containers

Chapter 7 Strings, Streams, and Formatting

- String formatting
- Example code
- Using the string_view class as a lightweight string object
- Concatenate strings
- Transforming strings
- Formatting text with C++20's format library
- Remove spaces from a string
- Reading strings from user input
- Count the number of words in a file
- Initializing complex structures with file input
- Customizing string classes with char_traits
- Parsing strings with regular expressions

Chapter 8 Utility Classes

- Example code
- Managing optional values ​​with std::optional
- Using std::any for type safety
- Storing different types with std::variant
- Handling time events with std::chrono
- Using fold expressions for mutable tuples
- Managing memory allocated with std::unique_ptr
- Sharing objects with std::shared_ptr
- Using weak pointers for shared objects
- Sharing members of managed objects
- Comparing random number engines
- Comparing random number distribution generators

Chapter 9 Concurrency and Parallelism

- Example code
- Sleep for a specific period of time
- Using std::thread for concurrency
- Using std::async for concurrency
- Execute STL algorithms in parallel according to execution policy
- Sharing data safely with mutexes and locks
- Sharing flags and values ​​with std::atomic
- Initializing threads with std::call_once
- Solving the producer-consumer problem using std::condition_variable
- Implementing multiple producers and consumers

Chapter 10: Using the File System

- Example code
- Specializing std::formatter for the path class
- Using manipulation functions for path
- Listing files in a directory
- Finding directories and files with the grep utility
- Renaming files with regex and directory_iterator
- Create a disk usage counter

Chapter 11: Topics to Consider

- Example code
- Creating a trie class for search suggestions
- Calculating the sum of the errors of two vectors
- Create your own split algorithm
- Creating a gather algorithm that leverages existing algorithms
- Remove consecutive spaces
- Convert numbers to words

Detailed image
Detailed Image 1

Publisher's Review
《Learning C++ STL with Examples》 is a book designed to help you learn the core concepts of STL in the most practical and systematic way possible, based on the latest C++20 standard.

Many C++ developers find the vast functionality and complex syntax of the STL overwhelming.
In particular, many people are concerned about how to apply it in practice and how it differs from existing methods.
This book was designed to address such concerns.

Beyond simple grammar explanations, it provides a variety of examples of how to use STL and why to use it that way, focusing on problems encountered in actual development settings.
Each example is a code recipe that can be applied immediately to real-world situations, so you can start using it right away.

It's also designed to provide practical help to developers of all levels, from those new to the STL, to those familiar with traditional C++, to experienced developers looking to modernize their code to the latest standards.

This book is highly recommended for those who want to learn STL properly, those who want to learn modern C++ thinking, and those who want to learn by focusing on practical code.


Master the world of STL accurately and quickly with “Learn C++ STL with Examples” right now.
GOODS SPECIFICS
- Date of issue: April 15, 2025
- Page count, weight, size: 480 pages | 188*257*30mm
- ISBN13: 9788931479409
- ISBN10: 8931479409

You may also like

카테고리