Part I: Introduction and Philosophy of Good C++....7
1: Introduction To The C++23 Edition....8
2: Introduction To The Original Edition....9
3: About Best Practices....10
4: Slow Down....12
5: Use AI Coding Assistants Judiciously....13
6: C++ Is Not Magic....14
7: Remember: C++ Is Not Object-Oriented....16
8: Learn Another Language....17
9: Know Your Standard Library....19
10: Use The Tools....20
11: Don’t Invoke Undefined Behavior....21
12: Never Test for this To Be nullptr It’s UB....22
13: Never Test for A Reference To Be nullptr It’s UB....25
Part II: Use The Tools....26
14: Use the Tools: Automated Tests....28
15: Use the Tools: Continuous Builds....30
16: Use the Tools: Compiler Warnings....31
17: Use the Tools: Static Analysis....33
18: Use The Tools: Consider Custom Static Analysis....34
19: Use the Tools: Sanitizers....35
20: Use The Tools: Hardening....37
21: Use the Tools: Multiple Compilers....38
22: Use The Tools: Fuzzing and Mutating....40
23: Use the Tools: Build Generators....44
24: Use the Tools: Package Managers....46
Part III: API and Code Design Guidelines....47
25: Make your interfaces hard to use wrong.....49
26: Consider If Using the API Wrong Invokes Undefined Behavior....50
27: Be Afraid of Global State....51
28: Use Stronger Types....52
29: Use [[nodiscard]] Liberally....55
30: Forget Header Files Exist....57
31: Export Module Overloads Consistently....59
32: Prefer Stack Over Heap....62
33: Don’t return raw pointers....64
34: Know Your Containers....65
35: Be Aware of Custom Allocation And PMR....67
36: Constrain Your Template Parameters With Concepts....69
37: Understand consteval and constinit....72
38: Prefer Spaceships....75
39: Follow the Rule of 0....76
40: If You Must Do Manual Resource Management, Follow the Rule of 5....78
Part IV: Code Implementation Guidelines....80
41: Don’t Copy and Paste Code....82
42: Prefer format Over iostream Or c-formatting Functions....83
43: constexpr All The Things!....85
44: Make globals in headers inline constexpr....88
45: const Everything That’s Not constexpr....89
46: Always Initialize Your non-const non-auto Values....91
47: Prefer auto in Many Cases.....93
48: Use Ranges and Views For Correctness and Readability....97
49: Don’t Reuse Views....99
50: Prefer Algorithms Over Loops....101
51: Use Ranged-For Loops When Views and Algorithms Cannot Help....102
52: Use auto in ranged for loops....104
53: Avoid default In switch Statements....106
54: Prefer Scoped enum....109
55: Prefer if constexpr over SFINAE....111
56: De-template-ize Your Generic Code....114
57: Use Lippincott Functions....115
58: No More new....117
59: Avoid std::bind and std::function....118
60: Don’t Use initializer_list For Non-Trivial Types....122
61: Consider Designated Initializers (C++20)....123
Part V: Bonus Chapters....125
62: Improving Build Time....127
63: Continue Your C++ Education....128
64: Thank You....130
65: Bonus: Understand The Lambda....131
Level up your C++, get the tools working for you, eliminate common problems, and move on to more exciting things! This version is printed with full color syntax highlighted examples. A black and white only edition is available for less.As a C++ developer and trainer for 20 years, I have learned that there are many common mistakes that C++ developers of all experience levels make. This book distills that experience down into the most important things to address to make your code faster, easier to maintain, and more portable.Most sections have one or more exercises that help you apply what is discussed in a practical way in the code you are currently working on.This book is intentionally concise! Expect short sections for each item! I use as few words as possible to get across the point and get you applying what you learned to your code.If you follow me and watch all of my talks this book will present little new information to you. Why should you buy it then? Because I've consolidated the most important items and given you exercises to apply the rules in your code.