Mastering the C++17 STL

This book breaks down the C++ STL, teaching you how to extract its gems and apply them to your programming.
Preview in Mapt

Mastering the C++17 STL

Arthur O'Dwyer

3 customer reviews
This book breaks down the C++ STL, teaching you how to extract its gems and apply them to your programming.

Quick links: > What will you learn?> Table of content> Product reviews

eBook
$25.20
RRP $35.99
Save 29%
Print + eBook
$44.99
RRP $44.99
What do I get with a Mapt Pro subscription?
  • Unlimited access to all Packt’s 5,000+ eBooks and Videos
  • Early Access content, Progress Tracking, and Assessments
  • 1 Free eBook or Video to download and keep every month after trial
What do I get with an eBook?
  • Download this book in EPUB, PDF, MOBI formats
  • DRM FREE - read and interact with your content when you want, where you want, and how you want
  • Access this title in the Mapt reader
What do I get with Print & eBook?
  • Get a paperback copy of the book delivered to you
  • Download this book in EPUB, PDF, MOBI formats
  • DRM FREE - read and interact with your content when you want, where you want, and how you want
  • Access this title in the Mapt reader
What do I get with a Video?
  • Download this Video course in MP4 format
  • DRM FREE - read and interact with your content when you want, where you want, and how you want
  • Access this title in the Mapt reader
$25.20
$44.99
RRP $35.99
RRP $44.99
eBook
Print + eBook

Frequently bought together


Mastering the C++17 STL Book Cover
Mastering the C++17 STL
$ 35.99
$ 25.20
Boost C++ Application Development Cookbook - Second Edition Book Cover
Boost C++ Application Development Cookbook - Second Edition
$ 39.99
$ 28.00
Buy 2 for $35.00
Save $40.98
Add to Cart

Book Details

ISBN 139781787126824
Paperback384 pages

Book Description

Modern C++ has come a long way since 2011. The latest update, C++17, has just been ratified and several implementations are on the way.

This book is your guide to the C++ standard library, including the very latest C++17 features.

The book starts by exploring the C++ Standard Template Library in depth. You will learn the key differences between classical polymorphism and generic programming, the foundation of the STL. You will also learn how to use the various algorithms and containers in the STL to suit your programming needs. The next module delves into the tools of modern C++. Here you will learn about algebraic types such as std::optional, vocabulary types such as std::function, smart pointers, and synchronization primitives such as std::atomic and std::mutex. In the final module, you will learn about C++'s support for regular expressions and file I/O.

By the end of the book you will be proficient in using the C++17 standard library to implement real programs, and you'll have gained a solid understanding of the library's own internals.

Table of Contents

Chapter 1: Classical Polymorphism and Generic Programming
Concrete monomorphic functions
Classically polymorphic functions
Generic programming with templates
Summary
Chapter 2: Iterators and Ranges
The problem with integer indices
On beyond pointers
Const iterators
A pair of iterators defines a range
Iterator categories
Input and output iterators
Putting it all together
The deprecated std::iterator
Summary
Chapter 3: The Iterator-Pair Algorithms
A note about headers
Read-only range algorithms
Shunting data with std::copy
Variations on a theme - std::move and std::move_iterator
Complicated copying with std::transform
Write-only range algorithms
Algorithms that affect object lifetime
Our first permutative algorithm: std::sort
Swapping, reversing, and partitioning
Rotation and permutation
Heaps and heapsort
Merges and mergesort
Searching and inserting in a sorted array with std::lower_bound
Deleting from a sorted array with std::remove_if
Summary
Chapter 4: The Container Zoo
The notion of ownership
The simplest container: std::array<T, N>
The workhorse: std::vector<T>
The speedy hybrid: std::deque<T>
A particular set of skills: std::list<T>
Roughing it with std::forward_list<T>
Abstracting with std::stack<T> and std::queue<T>
The useful adaptor: std::priority_queue<T>
The trees: std::set<T> and std::map<K, V>
Oddballs: std::multiset<T> and std::multimap<K, V>
The hashes: std::unordered_set<T> and std::unordered_map<K, V>
Where does the memory come from?
Summary
Chapter 5: Vocabulary Types
The story of std::string
Tagging reference types with reference_wrapper
C++11 and algebraic types
Working with std::tuple
Expressing alternatives with std::variant
Delaying initialization with std::optional
Revisiting variant
Infinite alternatives with std::any
Type erasure in a nutshell
Again with the type erasure: std::function
Summary
Chapter 6: Smart Pointers
The origins of smart pointers
Smart pointers never forget
Automatically managing memory with std::unique_ptr<T>
Reference counting with std::shared_ptr<T>
Denoting un-special-ness with observer_ptr<T>
Summary
Chapter 7: Concurrency
The problem with volatile
Using std::atomic<T> for thread-safe accesses
Taking turns with std::mutex
Always associate a mutex with its controlled data
Special-purpose mutex types
Waiting for a condition
Promises about futures
Packaging up tasks for later
The future of futures
Speaking of threads...
Thread exhaustion and std::async
Building your own thread pool
Summary
Chapter 8: Allocators
An allocator is a handle to a memory resource
Defining a heap with memory_resource
Using the standard memory resources
The 500 hats of the standard allocator
Sticking a container to a single memory resource
Using the standard allocator types
Making a container allocator-aware
Propagating downwards with scoped_allocator_adaptor
Summary
Chapter 9: Iostreams
The trouble with I/O in C++
Buffering versus formatting
Using the POSIX API
Using the standard C API
The classical iostreams hierarchy
Converting numbers to strings
Converting strings to numbers
Reading a line or word at a time
Summary
Chapter 10: Regular Expressions
What are regular expressions?
Reifying regular expressions into std::regex objects
Matching and searching
Iterating over multiple matches
Using regular expressions for string replacement
A primer on the ECMAScript regex grammar
Summary
Chapter 11: Random Numbers
Random numbers versus pseudo-random numbers
The problem with rand()
Solving problems with <random>
Dealing with generators
Dealing with distributions
Summary
Chapter 12: Filesystem
A note about namespaces
A very long note on error-reporting
Filesystems and paths
Statting files with directory_entry
Walking directories with directory_iterator
Modifying the filesystem
Reporting disk usage
Summary

What You Will Learn

  • Make your own iterator types, allocators, and thread pools.
  • Master every standard container and every standard algorithm.
  • Improve your code by replacing new/delete with smart pointers.
  • Understand the difference between monomorphic algorithms, polymorphic algorithms, and generic algorithms.
  • Learn the meaning and applications of vocabulary type, product type and sum type.

Authors

Table of Contents

Chapter 1: Classical Polymorphism and Generic Programming
Concrete monomorphic functions
Classically polymorphic functions
Generic programming with templates
Summary
Chapter 2: Iterators and Ranges
The problem with integer indices
On beyond pointers
Const iterators
A pair of iterators defines a range
Iterator categories
Input and output iterators
Putting it all together
The deprecated std::iterator
Summary
Chapter 3: The Iterator-Pair Algorithms
A note about headers
Read-only range algorithms
Shunting data with std::copy
Variations on a theme - std::move and std::move_iterator
Complicated copying with std::transform
Write-only range algorithms
Algorithms that affect object lifetime
Our first permutative algorithm: std::sort
Swapping, reversing, and partitioning
Rotation and permutation
Heaps and heapsort
Merges and mergesort
Searching and inserting in a sorted array with std::lower_bound
Deleting from a sorted array with std::remove_if
Summary
Chapter 4: The Container Zoo
The notion of ownership
The simplest container: std::array<T, N>
The workhorse: std::vector<T>
The speedy hybrid: std::deque<T>
A particular set of skills: std::list<T>
Roughing it with std::forward_list<T>
Abstracting with std::stack<T> and std::queue<T>
The useful adaptor: std::priority_queue<T>
The trees: std::set<T> and std::map<K, V>
Oddballs: std::multiset<T> and std::multimap<K, V>
The hashes: std::unordered_set<T> and std::unordered_map<K, V>
Where does the memory come from?
Summary
Chapter 5: Vocabulary Types
The story of std::string
Tagging reference types with reference_wrapper
C++11 and algebraic types
Working with std::tuple
Expressing alternatives with std::variant
Delaying initialization with std::optional
Revisiting variant
Infinite alternatives with std::any
Type erasure in a nutshell
Again with the type erasure: std::function
Summary
Chapter 6: Smart Pointers
The origins of smart pointers
Smart pointers never forget
Automatically managing memory with std::unique_ptr<T>
Reference counting with std::shared_ptr<T>
Denoting un-special-ness with observer_ptr<T>
Summary
Chapter 7: Concurrency
The problem with volatile
Using std::atomic<T> for thread-safe accesses
Taking turns with std::mutex
Always associate a mutex with its controlled data
Special-purpose mutex types
Waiting for a condition
Promises about futures
Packaging up tasks for later
The future of futures
Speaking of threads...
Thread exhaustion and std::async
Building your own thread pool
Summary
Chapter 8: Allocators
An allocator is a handle to a memory resource
Defining a heap with memory_resource
Using the standard memory resources
The 500 hats of the standard allocator
Sticking a container to a single memory resource
Using the standard allocator types
Making a container allocator-aware
Propagating downwards with scoped_allocator_adaptor
Summary
Chapter 9: Iostreams
The trouble with I/O in C++
Buffering versus formatting
Using the POSIX API
Using the standard C API
The classical iostreams hierarchy
Converting numbers to strings
Converting strings to numbers
Reading a line or word at a time
Summary
Chapter 10: Regular Expressions
What are regular expressions?
Reifying regular expressions into std::regex objects
Matching and searching
Iterating over multiple matches
Using regular expressions for string replacement
A primer on the ECMAScript regex grammar
Summary
Chapter 11: Random Numbers
Random numbers versus pseudo-random numbers
The problem with rand()
Solving problems with <random>
Dealing with generators
Dealing with distributions
Summary
Chapter 12: Filesystem
A note about namespaces
A very long note on error-reporting
Filesystems and paths
Statting files with directory_entry
Walking directories with directory_iterator
Modifying the filesystem
Reporting disk usage
Summary

Book Details

ISBN 139781787126824
Paperback384 pages
Read More
From 3 reviews

Read More Reviews

Recommended for You

Boost C++ Application Development Cookbook - Second Edition Book Cover
Boost C++ Application Development Cookbook - Second Edition
$ 39.99
$ 28.00
Understanding Software Book Cover
Understanding Software
$ 23.99
$ 16.80
Learning C++ Functional Programming Book Cover
Learning C++ Functional Programming
$ 39.99
$ 28.00
Mastering Assembly Programming Book Cover
Mastering Assembly Programming
$ 35.99
$ 25.20
Practical Time Series Analysis Book Cover
Practical Time Series Analysis
$ 35.99
$ 25.20
C++ GUI Programming with QT5 Book Cover
C++ GUI Programming with QT5
$ 35.99
$ 25.20