Boring C++
Table of Contents
3 min read
Table of Contents
Front Matter
- Preface
- About the Author
Chapter 1 – Introduction: Why C++ in 2026?
- 1.1 The honest case for C++
- 1.2 "Modern" means C++11 and later
- 1.3 Who this book is for (and who it is not for)
- 1.4 What you will need
- 1.5 How the book is organized
- 1.6 A realistic expectation of the difficulty curve
- 1.7 The "boring" philosophy
- 1.8 Let's get started
Chapter 2 – Setup: Compiler, Editor, and Your First Program
- 2.1 Choosing a compiler
- 2.2 Installing on Linux, macOS, and Windows
- 2.3 Your editor
- 2.4 Your first C++ program: Hello, world
- 2.5 The build command explained
- 2.6 CMake: the boring minimum
- 2.7 Common installation problems and fixes
- 2.8 Summary
Chapter 3 – Types, Variables, and Control Flow
- 3.1 Fundamental types
- 3.2 auto and type deduction
- 3.3 const, constexpr, and literals
- 3.4 Enums and enum class
- 3.5 Control flow: if, switch, and loops
- 3.6 Range-based for loops
- 3.7 Structured bindings (C++17)
- 3.8 Exercises
- 3.9 Common mistakes
- 3.10 Summary
Chapter 4 – Functions, Lambdas, and Callables
- 4.1 Function basics and overloading
- 4.2 Default arguments
- 4.3 Pass by value, reference, and const reference
- 4.4 Lambda expressions
- 4.5 Capturing variables in lambdas
- 4.6 std::function
- 4.7 Function pointers (briefly)
- 4.8 Exercises
- 4.9 Common mistakes
- 4.10 Summary
Chapter 5 – Classes and Objects
- 5.1 Why classes exist
- 5.2 Members, methods, and access control
- 5.3 Constructors and destructors
- 5.4 The Rule of Zero, Three, and Five
- 5.5 Operator overloading
- 5.6 Inheritance and virtual dispatch
- 5.7 Abstract classes and interfaces
- 5.8 Exercises
- 5.9 Common mistakes
- 5.10 Summary
Chapter 6 – Memory: Ownership and Lifetime
- 6.1 Stack versus heap
- 6.2 Raw pointers (and why to avoid them)
- 6.3 unique_ptr
- 6.4 shared_ptr and weak_ptr
- 6.5 References versus pointers
- 6.6 Move semantics: what actually happens
- 6.7 RAII: the most important pattern in C++
- 6.8 Exercises
- 6.9 Common mistakes
- 6.10 Summary
Chapter 7 – Templates and Generic Programming
- 7.1 The problem templates solve
- 7.2 Function templates
- 7.3 Class templates
- 7.4 Template specialization
- 7.5 Concepts (C++20)
- 7.6 Variadic templates (brief introduction)
- 7.7 Exercises
- 7.8 Common mistakes
- 7.9 Summary
Chapter 8 – The Standard Library: Containers and Algorithms
- 8.1 std::vector
- 8.2 std::array
- 8.3 std::map and std::unordered_map
- 8.4 std::string and std::string_view
- 8.5 Iterators
- 8.6 Algorithms: sort, find, transform, and friends
- 8.7 Ranges (C++20)
- 8.8 Exercises
- 8.9 Common mistakes
- 8.10 Summary
Chapter 9 – Error Handling
- 9.1 Return codes versus exceptions
- 9.2 Throwing and catching exceptions
- 9.3 Writing exception-safe code
- 9.4 std::optional
- 9.5 std::expected (C++23)
- 9.6 When to use which strategy
- 9.7 Exercises
- 9.8 Common mistakes
- 9.9 Summary
Chapter 10 – Concurrency
- 10.1 Threads
- 10.2 Mutexes and lock_guard
- 10.3 Condition variables
- 10.4 std::atomic
- 10.5 std::async and futures
- 10.6 Coroutines: a first look (C++20)
- 10.7 Exercises
- 10.8 Common mistakes
- 10.9 Summary
Chapter 11 – Modern C++ Idioms and Best Practices
- 11.1 const-correctness
- 11.2 noexcept
- 11.3 Attributes: [[nodiscard]], [[maybe_unused]], [[likely]]
- 11.4 Compile-time programming: constexpr and consteval
- 11.5 std::span and std::mdspan
- 11.6 std::format (C++20)
- 11.7 Modules: a brief introduction (C++20)
- 11.8 Exercises
- 11.9 Common mistakes
- 11.10 Summary
Chapter 12 – A Complete Project: Command-Line Task Manager
- 12.1 What we will build
- 12.2 The data model
- 12.3 File I/O and serialization
- 12.4 Command parsing
- 12.5 Putting it all together
- 12.6 Adding tests
- 12.7 Timing and what to expect
- 12.8 Exercises
- 12.9 Common mistakes
- 12.10 Summary
Appendices
- Appendix A – C++ Quick Reference Card
- Appendix B – Standard Library Cheat Sheet
- Appendix C – Exercise Solutions
- Appendix D – Glossary
- Appendix E – Further Reading and Next Steps
Index