Share E-Book

Mastering the C++17 STL Make full use of the standard library components in C++17 (Arthur O’Dwyer)(Z-Library)

Author Arthur O’Dwyer

C/C++/C#
Language English

Key Features Boost your productivity as a C++ developer with the latest features of C++17 Develop high-quality, fast, and portable applications with the varied features of the STL Migrate from older versions (C++11, C++14) to C++17 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. 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

Format EPUB
Size 1.3 MB
168
Views
0
Downloads
0.00
Total Donations

AI Guide

AI Reading Assistant

Whole-book reading guide from stratified index samples; jump to passages in the text

Full assistant
AI guide
# Mastering the C++17 STL — Reading Guide ## 【One-Line Pitch】 A practical, deep-dive manual for experienced C++ developers who want to master the standard library's containers, algorithms, and modern vocabulary types — and understand how the STL actually works under the hood. If you already know C++ basics and want to move beyond "it compiles" to "it's idiomatic, efficient, and correct," this book is for you. ## 【Book Arc】 - **Opening (~0%–9%)**: Sets the intellectual foundation — contrasts classical OO polymorphism with generic programming, then introduces iterators and ranges as the core abstraction that makes STL algorithms container-agnostic. This stage solves the problem of writing algorithms that work across different data structures without sacrificing performance. - **Early (~9%–32%)**: Covers the iterator-pair algorithms (copy, move, transform, sort, heap operations) and the full "container zoo" — from `std::array` and `std::vector` through `std::list`, `std::set`, `std::map`, and the unordered family. Includes hands-on implementation of your own iterator types to show how the library's generic machinery actually works. - **Middle (~32%–56%)**: Moves into modern C++ vocabulary types — `std::optional`, `std::variant`, `std::any`, `std::function`, and `std::tuple` — followed by smart pointers (`std::unique_ptr`, `std::shared_ptr`) and synchronization primitives. This is where the book shifts from "using the STL" to "thinking in modern C++." - **Late (~56%–100%)**: Covers practical application areas: regular expressions with `std::regex`, random number generation with `<random>`, and the filesystem library. The final chapters emphasize real-world usage patterns, error handling with `<system_error>`, and directory traversal. ## 【Key Takeaways】 - **Iterators, not indices, are the foundation of STL algorithms** (Early): Integer indexing with `.at()` leads to O(n²) behavior on linked structures; a pair of iterators defines a range and works uniformly across containers. This is why every STL algorithm takes iterator pairs rather than container references. - **Generic programming beats classical polymorphism for performance** (Early): Virtual function dispatch parameterizes behavior at runtime, but templates do it at compile time — no vtable overhead, no loss of type information. The book shows concrete examples of the same algorithm implemented both ways. - **The five member typedefs make your types STL-compatible** (Early): `difference_type`, `value_type`, `pointer`, `reference`, and `iterator_category` are what `std::iterator_traits` needs to make custom iterators work with standard algorithms. The book walks through a complete `const`-correct iterator implementation. - **`std::move` (algorithm) and `std::move_iterator` solve different problems** (Middle): The three-argument `std::move` algorithm is cleaner for simple moves, but `move_iterator` lets you compose moving with other algorithms like `std::copy`. Understanding the distinction prevents subtle bugs. - **`std::sort` is a permutation, not a guarantee** (Middle): The standard sort doesn't preserve the relative order of equal elements — use `std::stable_sort` when that matters. The book also shows how heapsort is built from `push_heap`, `pop_heap`, and `sort_heap` primitives. - **Smart pointers replace `new`/`delete` but require discipline** (Middle): `std::unique_ptr` gives deterministic ownership, `std::shared_ptr` adds reference counting — but "don't double-manage" is the key warning. The book covers custom deleters and array management. - **Vocabulary types express intent in the type system** (Middle): `std::optional` says "may be absent," `std::variant` says "one of several types," `std::any` says "any type at runtime." These make APIs self-documenting and eliminate sentinel-value hacks. ## 【Reading Tips】 - **Skim the first chapter if you're comfortable with templates** — the OO-vs-generic comparison is valuable but basic; the real meat starts with iterators and ranges in Chapter 2. - **Deep-read the iterator implementation sections** (around 29%–32%): Writing your own `list_of_ints_iterator` and reimplementing `distance` and `count_if` is the best way to internalize how the STL's generic machinery works. - **Pay attention to the "why" behind design choices** — e.g., why `move_iterator` exists when `std::move` is simpler, or why `std::sort` doesn't guarantee stability. These explanations prevent real-world bugs. - **The heap algorithm section (around 53%) is skimmable** — the code is instructive but you can safely skip the implementation details if you just want to use `std::push_heap` and friends correctly. - **Use the later chapters (regex, random, filesystem) as reference** — they're practical but self-contained; read them when you need them rather than front-to-back. ## 【Coverage Limits】 The excerpts cover roughly the first half of the book in detail (through heaps and sorting); the later chapters on vocabulary types, smart pointers, regex, random numbers, and filesystem are listed in the table of contents but not deeply excerpted. Specific code examples from those sections are not covered in this guide. ##

Passage locations

Excerpt 1
STL Copyright © 2017 Packt Publishing   All rights reserved. No part of this book may be reproduced, stored in a retrieval system, or transmitted in any form...
View in text
Excerpt 2
tpub.com , and we will do our best to address the problem. Classically polymorphic functions Classically polymorphic functions We can increase the abstractio...
View in text
Excerpt 3
t list_of_ints_iterator<R>& rhs) const { return ptr_ != rhs.ptr_; } // Support implicit conversion of iterator to const_iterator // (but not vice versa) oper...
View in text
Excerpt 4
ther to provide this "messier" approach with move_iterator ? To answer that question, we'll have to explore yet another algorithm that is fundamentally relat...
View in text

Recommended for You

Loading recommended books...
Failed to load, please try again later

Tip the Site

Scan the WeChat Pay or Alipay code to tip. No login required.

WeChat Pay
Alipay
Back to List