Table of Contents

Open all
Close all
Preface
27
PART I Fundamentals
31
1 C++: The Comprehensive Guide
33
1.1 New and Modern
33
1.2 “Dan” Chapters
34
1.3 Presentation in This Book
35
1.4 Formatting Used
35
1.5 Let’s Talk Lingo
36
2 Programming in C++
37
2.1 Compiling
38
2.2 Translation Phases
39
2.3 Current Compilers
39
2.3.1 Gnu C++
40
2.3.2 Clang++ from LLVM
40
2.3.3 Microsoft Visual C++
40
2.3.4 Compiler in the Container
40
2.4 Development Environments
41
2.5 The Command Line under Ubuntu
43
2.5.1 Create a Program
44
2.5.2 Automate with Makefile
45
2.6 The Visual Studio Code IDE under Windows
46
2.7 Speed Up the Sample Program
53
3 C++ for Newcomers
55
4 The Basic Building Blocks of C++
63
4.1 A Quick Overview
66
4.1.1 Comments
66
4.1.2 The “include” Directive
66
4.1.3 The Standard Library
66
4.1.4 The “main()” Function
67
4.1.5 Types
67
4.1.6 Variables
67
4.1.7 Initialization
68
4.1.8 Output on the Console
69
4.1.9 Statements
69
4.2 A Detailed Walkthrough
70
4.2.1 Spaces, Identifiers, and Tokens
71
4.2.2 Comments
73
4.2.3 Functions and Arguments
74
4.2.4 Side Effect Operators
75
4.2.5 The “main” Function
76
4.2.6 Statements
78
4.2.7 Expressions
80
4.2.8 Allocations
81
4.2.9 Types
83
4.2.10 Variables: Declaration, Definition, and Initialization
89
4.2.11 Initialize with “auto”
90
4.2.12 Details on the Include Directive
92
4.2.13 Modules
93
4.2.14 Input and Output
94
4.2.15 The “std” Namespace
95
4.3 Operators
97
4.3.1 Operators and Operands
97
4.3.2 Overview of Operators
98
4.3.3 Arithmetic Operators
99
4.3.4 Bit-by-Bit Arithmetic
100
4.3.5 Composite Assignment
103
4.3.6 Post- and Preincrement and Post- and Predecrement
104
4.3.7 Relational Operators
104
4.3.8 Logical Operators
105
4.3.9 Pointer and Dereference Operators
106
4.3.10 Special Operators
107
4.3.11 Function-Like Operators
109
4.3.12 Operator Sequence
110
4.4 Built-In Data Types
111
4.4.1 Overview
112
4.4.2 Initialize Built-In Data Types
114
4.4.3 Integers
114
4.4.4 Floating-Point Numbers
127
4.4.5 Truth Values
141
4.4.6 Character Types
143
4.4.7 Complex Numbers
146
4.5 Undefined Behavior
149
5 Good Code, 1st Dan: Writing Readable Code
151
5.1 Comments
151
5.2 Documentation
152
5.3 Indentations and Line Length
153
5.4 Lines per Function and File
154
5.5 Brackets and Spaces
154
5.6 Names
156
6 Higher Data Types
159
6.1 The String Type “string”
160
6.1.1 Initialization
161
6.1.2 Functions and Methods
162
6.1.3 Other String Types
163
6.1.4 For Viewing Only: “string_view”
164
6.2 Streams
166
6.2.1 Input and Output Operators
166
6.2.2 “getline”
168
6.2.3 Files for Input and Output
168
6.2.4 Manipulators
170
6.2.5 The “endl” Manipulator
172
6.3 Container and Pointer
172
6.3.1 Container
172
6.3.2 Parameterized Types
173
6.4 The Simple Sequence Containers
174
6.4.1 “array”
174
6.4.2 “vector”
176
6.5 Algorithms
179
6.6 Pointers and C-Arrays
180
6.6.1 Pointer Types
180
6.6.2 C-Arrays
180
7 Functions
181
7.1 Declaration and Definition of a Function
182
7.2 Function Type
183
7.3 Using Functions
184
7.4 Defining a Function
185
7.5 More about Parameters
186
7.5.1 Call-by-Value
186
7.5.2 Call-by-Reference
187
7.5.3 Constant References
188
7.5.4 Call as Value, Reference, or Constant Reference?
189
7.6 Functional Body
190
7.7 Converting Parameters
192
7.8 Overloading Functions
194
7.9 Default Parameter
196
7.10 Arbitrary Number of Arguments
198
7.11 Alternative Notation for Function Declaration
198
7.12 Specialties
199
7.12.1 “noexcept”
199
7.12.2 Inline Functions
200
7.12.3 “constexpr”
200
7.12.4 Deleted Functions
201
7.12.5 Specialties in Class Methods
201
8 Statements in Detail
203
8.1 The Statement Block
206
8.1.1 Standalone Blocks and Variable Scope
207
8.2 The Empty Statement
208
8.3 Declaration Statement
209
8.3.1 Structured Binding
210
8.4 The Expression Statement
211
8.5 The “if” Statement
212
8.5.1 “if” with Initializer
215
8.5.2 Compile-Time “if”
215
8.6 The “while” Loop
216
8.7 The “do-while” Loop
218
8.8 The “for” Loop
219
8.9 The Range-Based “for” Loop
221
8.10 The “switch” Statement
222
8.11 The “break” Statement
227
8.12 The “continue” Statement
228
8.13 The “return” Statement
228
8.14 The “goto” Statement
229
8.15 The “try-catch” Block and “throw”
231
8.16 Summary
232
9 Expressions in Detail
233
9.1 Calculations and Side Effects
234
9.2 Types of Expressions
235
9.3 Literals
236
9.4 Identifiers
237
9.5 Parentheses
237
9.6 Function Call and Index Access
238
9.7 Assignment
238
9.8 Type Casting
240
10 Error Handling
243
10.1 Error Handling with Error Codes
245
10.2 What Is an Exception?
248
10.2.1 Throwing and Handling Exceptions
249
10.2.2 Unwinding the Call Stack
250
10.3 Minor Error Handling
251
10.4 Throwing the Exception Again: “rethrow”
251
10.5 The Order in “catch”
252
10.5.1 No “finally”
253
10.5.2 Standard Library Exceptions
253
10.6 Types for Exceptions
254
10.7 When an Exception Falls Out of “main”
255
11 Good Code, 2nd Dan: Modularization
257
11.1 Program, Library, Object File
257
11.2 Modules
258
11.3 Separating Functionalities
259
11.4 A Modular Example Project
260
11.4.1 Namespaces
263
11.4.2 Implementation
264
11.4.3 Using the Library
270
PART II Object-Oriented Programming and More
273
12 From Structure to Class
275
12.1 Initialization
278
12.2 Returning Custom Types
279
12.3 Methods Instead of Functions
280
12.4 The Better “print”
283
12.5 An Output Like Any Other
285
12.6 Defining Methods Inline
286
12.7 Separate Implementation and Definition
287
12.8 Initialization via Constructor
288
12.8.1 Member Default Values in Declaration
291
12.8.2 Constructor Delegation
292
12.8.3 Default Values for Constructor Parameters
293
12.8.4 Do Not Call the “init” Method in the Constructor
294
12.8.5 Exceptions in the Constructor
295
12.9 Struct or Class?
295
12.9.1 Encapsulation
297
12.9.2 “public” and “private”, Struct and Class
297
12.9.3 Data with “struct”, Behavior with “class”
298
12.9.4 Initialization of Types with Private Data
298
12.10 Interim Recap
299
12.11 Using Custom Data Types
300
12.11.1 Using Classes as Values
302
12.11.2 Using Constructors
305
12.11.3 Type Conversions
306
12.11.4 Encapsulate and Decapsulate
308
12.11.5 Give Types a Local Name
312
12.12 Type Inference with “auto”
315
12.13 Custom Classes in Standard Containers
319
12.13.1 Three-Way Comparison: The Spaceship Operator
321
13 Namespaces and Qualifiers
323
13.1 The “std” Namespace
324
13.2 Anonymous Namespace
327
13.3 “static” Makes Local
329
13.4 “static” Likes to Share
330
13.5 Remote Initialization or “static inline” Data Fields
332
13.6 Guaranteed to Be Initialized at Compile Time with “constinit”
333
13.7 “static” Makes Permanent
333
13.8 “inline namespace”
335
13.9 Interim Recap
336
13.10 “const”
337
13.10.1 Const Parameters
338
13.10.2 Const Methods
339
13.10.3 “const” Variables
341
13.10.4 Const Returns
342
13.10.5 “const” Together with “static”
346
13.10.6 Even More Constant with “constexpr”
347
13.10.7 “if constexpr” for Compile-Time Decisions
350
13.10.8 C++20: “consteval”
352
13.10.9 “if consteval”
354
13.10.10 Un-“const” with “mutable”
355
13.10.11 Const-Correctness
355
13.10.12 Summary
357
13.11 Volatile with “volatile”
357
14 Good Code, 3rd Dan: Testing
361
14.1 Types of Tests
361
14.1.1 Refactoring
362
14.1.2 Unit Tests
363
14.1.3 Social or Solitary
364
14.1.4 Doppelgangers
366
14.1.5 Suites
367
14.2 Frameworks
368
14.2.1 Arrange, Act, Assert
370
14.2.2 Frameworks to Choose From
371
14.3 Boost.Test
372
14.4 Helper Macros for Assertions
376
14.5 An Example Project with Unit Tests
379
14.5.1 Private and Public Testing
380
14.5.2 An Automatic Test Module
381
14.5.3 Compile Test
384
14.5.4 Assemble the Test Suite Yourself
384
14.5.5 Testing Private Members
388
14.5.6 Parameterized Tests
389
15 Inheritance
391
15.1 Relationships
392
15.1.1 Has-a Composition
392
15.1.2 Has-a Aggregation
392
15.1.3 Is-a Inheritance
393
15.1.4 Instance-of versus Is-a Relationship
394
15.2 Inheritance in C++
394
15.3 Has-a versus Is-a
395
15.4 Finding Commonalities
396
15.5 Derived Types Extend
398
15.6 Overriding Methods
399
15.7 How Methods Work
400
15.8 Virtual Methods
402
15.9 Constructors in Class Hierarchies
404
15.10 Type Conversion in Class Hierarchies
405
15.10.1 Converting Up the Inheritance Hierarchy
405
15.10.2 Downcasting the Inheritance Hierarchy
406
15.10.3 References Also Retain Type Information
406
15.11 When to Use Virtual?
407
15.12 Other Designs for Extensibility
409
16 The Lifecycle of Classes
411
16.1 Creation and Destruction
412
16.2 Temporary: Short-Lived Values
414
16.3 The Destructor to the Constructor
416
16.3.1 No Destructor Needed
418
16.3.2 Resources in the Destructor
418
16.4 Yoda Condition
420
16.5 Construction, Destruction, and Exceptions
421
16.6 Copy
423
16.7 Assignment Operator
426
16.8 Removing Methods
429
16.9 Move Operations
430
16.9.1 What the Compiler Generates
434
16.10 Operators
435
16.11 Custom Operators in a Data Type
438
16.12 Special Class Forms
446
16.12.1 Abstract Classes and Methods
446
16.12.2 Enumeration Classes
448
17 Good Code, 4th Dan: Security, Quality, and Sustainability
451
17.1 The Rule of Zero
451
17.1.1 The Big Five
451
17.1.2 Helper Construct by Prohibition
452
17.1.3 The Rule of Zero and Its Application
453
17.1.4 Exceptions to the Rule of Zero
454
17.1.5 Rule of Zero, Rule of Three, Rule of Five, Rule of Four and a Half
456
17.2 Resource Acquisition Is Initialization
457
17.2.1 An Example with C
457
17.2.2 Owning Raw Pointers
459
17.2.3 From C to C++
460
17.2.4 It Doesn't Always Have to Be an Exception
462
17.2.5 Multiple Constructors
463
17.2.6 Multiphase Initialization
464
17.2.7 Define Where It Is Needed
464
17.2.8 “new” without Exceptions
464
18 Specials for Classes
467
18.1 Allowed to See Everything: “friend” Classes
467
18.1.1 “friend class” Example
469
18.2 Nonpublic Inheritance
471
18.2.1 Impact on the Outside World
473
18.2.2 Nonpublic Inheritance in Practice
475
18.3 Signature Classes as Interfaces
477
18.4 Multiple Inheritance
481
18.4.1 Multiple Inheritance in Practice
483
18.4.2 Caution with Pointer Type Conversions
487
18.4.3 The Observer Pattern as a Practical Example
489
18.5 Diamond-Shaped Multiple Inheritance: “virtual” for Class Hierarchies
490
18.6 Literal Data Types: “constexpr” for Constructors
495
19 Good Code, 5th Dan: Classical Object-Oriented Design
497
19.1 Objects in C++
499
19.2 Object-Oriented Design
500
19.2.1 SOLID
500
19.2.2 Don't Be STUPID
516
PART III Advanced Topics
519
20 Pointers
521
20.1 Addresses
522
20.2 Pointer
523
20.3 Dangers of Aliasing
525
20.4 Heap Memory and Stack Memory
526
20.4.1 The Stack
526
20.4.2 The Heap
528
20.5 Smart Pointers
530
20.5.1 “unique_ptr”
532
20.5.2 “shared_ptr”
536
20.6 Raw Pointers
539
20.7 C-Arrays
543
20.7.1 Calculating with Pointers
544
20.7.2 Decay of C-Arrays
545
20.7.3 Dynamic C-Arrays
547
20.7.4 String Literals
548
20.8 Iterators
550
20.9 Pointers as Iterators
551
20.10 Pointers in Containers
552
20.11 The Exception: When Cleanup Is Not Necessary
552
21 Macros
555
21.1 The Preprocessor
556
21.2 Beware of Missing Parenthesis
560
21.3 Feature Macros
561
21.4 Information about the Source Code
561
21.5 Warning about Multiple Executions
562
21.6 Type Variability of Macros
563
21.7 Summary
566
22 Interface to C
567
22.1 Working with Libraries
568
22.2 C Header
569
22.3 C Resources
572
22.4 “void” Pointers
572
22.5 Reading Data
573
22.6 The Main Program
575
22.7 Summary
575
23 Templates
577
23.1 Function Templates
578
23.1.1 Overloading
579
23.1.2 A Type as Parameter
580
23.1.3 Function Body of a Function Template
580
23.1.4 Values as Template Parameters
583
23.1.5 Many Functions
584
23.1.6 Parameters with Extras
585
23.1.7 Method Templates are Just Function Templates
587
23.2 Function Templates in the Standard Library
588
23.2.1 Ranges instead of Containers as Template Parameters
589
23.2.2 Example: Information about Numbers
592
23.3 A Class as a Function
593
23.3.1 Values for a “Function” Parameter
594
23.3.2 C Function Pointer
595
23.3.3 The Somewhat Different Function
597
23.3.4 Practical Functors
600
23.3.5 Algorithms with Functors
602
23.3.6 Anonymous Functions: a.k.a. Lambda Expressions
602
23.3.7 Template Functions without “template”, but with “auto”
608
23.4 C++ Concepts
609
23.4.1 How to Read Concepts
609
23.4.2 How to Use Concepts
612
23.4.3 How to Write Concepts
614
23.4.4 Semantic Constraints
615
23.4.5 Interim Recap
616
23.5 Template Classes
616
23.5.1 Implementing Class Templates
617
23.5.2 Implementing Methods of Class Templates
618
23.5.3 Creating Objects from Class Templates
620
23.5.4 Class Templates with Multiple Formal Data Types
623
23.5.5 Class Templates with Nontype Parameters
625
23.5.6 Class Templates with Defaults
626
23.5.7 Specializing Class Templates
628
23.6 Templates with Variable Argument Count
630
23.6.1 “sizeof ...” Operator
633
23.6.2 Convert Parameter Pack to Tuple
633
23.7 Custom Literals
634
23.7.1 What Are Literals?
635
23.7.2 Naming Rules
635
23.7.3 Literal Processing Phases
636
23.7.4 Overloading Variants
636
23.7.5 User-Defined Literal Using Template
638
23.7.6 Raw or Cooked
641
23.7.7 Automatically Merged
642
23.7.8 Unicode Literals
642
PART IV The Standard Library
645
24 Containers
647
24.1 Basics
648
24.1.1 Recurring
648
24.1.2 Abstract
649
24.1.3 Operations
650
24.1.4 Complexity
651
24.1.5 Containers and Their Iterators
653
24.1.6 Ranges Simplify Iterators
656
24.1.7 Ranges, Views, Concepts, Adapters, Generators, and Algorithms
659
24.1.8 Algorithms
660
24.2 Iterator Basics
660
24.2.1 Iterators from Containers
662
24.2.2 More Functionality with Iterators
663
24.3 Allocators: Memory Issues
665
24.4 Container Commonalities
668
24.5 An Overview of the Standard Container Classes
669
24.5.1 Type Aliases of Containers
670
24.6 The Sequential Container Classes
673
24.6.1 Commonalities and Differences
675
24.6.2 Methods of Sequence Containers
677
24.6.3 “vector”
679
24.6.4 “array”
698
24.6.5 “deque”
704
24.6.6 “list”
708
24.6.7 “forward_list”
711
24.7 Associative and Ordered
716
24.7.1 Commonalities and Differences
717
24.7.2 Methods of Ordered Associative Containers
718
24.7.3 “set”
719
24.7.4 “map”
733
24.7.5 “multiset”
740
24.7.6 “multimap”
745
24.8 Only Associative and Not Guaranteed
749
24.8.1 Hash Tables
749
24.8.2 Commonalities and Differences
754
24.8.3 Methods of Unordered Associative Containers
756
24.8.4 “unordered_set”
757
24.8.5 “unordered_map”
766
24.8.6 “unordered_multiset”
770
24.8.7 “unordered_multimap”
776
24.9 Container Adapters
779
24.10 Special Cases: “string”, “basic_string”, and “vector<char>”
781
24.11 Special Cases: “vector<bool>”, “array<bool,n>”, and “bitset<n>”
782
24.11.1 Dynamic and Compact: “vector<bool>”
783
24.11.2 Static: “array<bool,n>” and “bitset<n>”
783
24.12 Special Case: Value Array with “valarray<>”
786
24.12.1 Element Properties
787
24.12.2 Initialize
789
24.12.3 Assignment
789
24.12.4 Insert and Delete
790
24.12.5 Accessing
790
24.12.6 Specialty: Manipulate All Data
790
24.12.7 Specialty: Slicing and Masking
791
25 Container Support
795
25.1 Algorithms
796
25.2 Iterators and Ranges
798
25.3 Iterator Adapter
800
25.4 Algorithms of the Standard Library
800
25.5 Parallel Execution
802
25.6 Lists of Algorithm Functions and Range Adapters
805
25.6.1 Range Adapters and Views
806
25.6.2 Ranges as Parameters (and More)
813
25.6.3 List of Nonmodifying Algorithms
815
25.6.4 Inherently Modifying Algorithms
820
25.6.5 Algorithms for Partitions
825
25.6.6 Algorithms for Sorting and Fast Searching in Sorted Ranges
826
25.6.7 Set Algorithms Represented by a Sorted Range
827
25.6.8 Heap Algorithms
829
25.6.9 Minimum and Maximum
830
25.6.10 Various Algorithms
830
25.7 Element-Linking Algorithms from “<numeric>” and “<ranges>”
831
25.8 Copy instead of Assignment: Values in Uninitialized Memory Areas
838
25.9 Custom Algorithms
840
25.10 Writing Custom Views and Range Adapters
842
26 Good Code, 6th Dan: The Right Container for Each Task
845
26.1 All Containers Arranged by Aspects
845
26.1.1 When Is a “vector” Not the Best Choice?
845
26.1.2 Always Sorted: “set”, “map”, “multiset”, and “multimap”
846
26.1.3 In Memory Contiguously: “vector”, “array”
846
26.1.4 Cheap Insertion: “list”
847
26.1.5 Low Memory Overhead: “vector”, “array”
848
26.1.6 Size Dynamic: All Except “array”
849
26.2 Recipes for Containers
850
26.2.1 Two Phases? “vector” as a Good “set” Replacement
850
26.2.2 Output the Contents of a Container to a Stream
852
26.2.3 So “array” Is Not That Static
852
26.3 Implementing Algorithms That Are Specialized Depending on the Container
856
27 Streams, Files, and Formatting
857
27.1 Input and Output Concept with Streams
857
27.2 Global, Predefined Standard Streams
858
27.2.1 Stream Operators << and >>
859
27.3 Methods for Stream Input and Output
860
27.3.1 Methods for Unformatted Output
860
27.3.2 Methods for Unformatted Input
862
27.4 Error Handling and Stream States
864
27.4.1 Methods for Handling Stream Errors
865
27.5 Manipulating and Formatting Streams
867
27.5.1 Manipulators
868
27.5.2 Creating Custom Manipulators without Arguments
873
27.5.3 Creating Custom Manipulators with Arguments
875
27.5.4 Directly Change Format Flags
876
27.6 Streams for File Input and Output
879
27.6.1 The “ifstream”, “ofstream”, and “fstream” Streams
879
27.6.2 Connecting to a File
879
27.6.3 Reading and Writing
884
27.6.4 Random Access
890
27.6.5 Synchronized Streams for Threads
891
27.7 Streams for Strings
892
27.7.1 Difference from “to_string”
896
27.7.2 “to_chars” and “format” Are More Flexible than “to_string”
897
27.7.3 Reading from a String
897
27.8 Stream Buffers
898
27.8.1 Access to the Stream Buffer of “iostream” Objects
899
27.8.2 “filebuf”
900
27.8.3 “stringbuf”
900
27.9 “filesystem”
900
27.10 Formatting
902
27.10.1 Simple Formatting
903
27.10.2 Formatting Custom Types
905
28 Standard Library: Extras
909
28.1 “pair” and “tuple”
909
28.1.1 Returning Multiple Values
910
28.2 Regular Expressions
917
28.2.1 Matching and Searching
918
28.2.2 The Result and Parts of It
918
28.2.3 Found Replacement
919
28.2.4 Rich in Variants
919
28.2.5 Iterators
920
28.2.6 Matches
920
28.2.7 Options
921
28.2.8 Speed
921
28.2.9 Standard Syntax, Slightly Shortened
922
28.2.10 Notes on Regular Expressions in C++
923
28.3 Randomness
926
28.3.1 Rolling a Die
927
28.3.2 True Randomness
929
28.3.3 Other Generators
929
28.3.4 Distributions
931
28.4 Mathematical
935
28.4.1 Fraction and Time: “<ratio>” and “<chrono>”
935
28.4.2 Predefined Suffixes for User-Defined Literals
957
28.5 System Error Handling with “system_error”
960
28.5.1 Overview
960
28.5.2 Principles
961
28.5.3 “error_code” and “error_condition”
962
28.5.4 Error Categories
966
28.5.5 Custom Error Codes
966
28.5.6 “system_error” Exception
967
28.6 Runtime Type Information: “<typeinfo>” and “<typeindex>”
968
28.7 Helper Classes around Functors: “<functional>”
972
28.7.1 Function Objects
973
28.7.2 Function Generators
977
28.8 “optional” for a Single Value or No Value
980
28.9 “variant” for One of Several Types
980
28.10 “any” Holds Any Type
982
28.11 Special Mathematical Functions
983
28.12 Fast Conversion with “<charconv>”
984
29 Threads: Programming with Concurrency
987
29.1 C++ Threading Basics
988
29.1.1 Starting Pure Threads
989
29.1.2 Terminating a Thread Prematurely
990
29.1.3 Waiting for a Thread
991
29.1.4 Consider Exceptions in the Starting Thread
992
29.1.5 Passing Parameters to a Thread Function
995
29.1.6 Moving a Thread
1000
29.1.7 How Many Threads to Start?
1002
29.1.8 Which Thread Am I?
1004
29.2 Shared Data
1005
29.2.1 Data Races
1005
29.2.2 Latch
1008
29.2.3 Barriers
1008
29.2.4 Mutexes
1010
29.2.5 Interface Design for Multithreading
1012
29.2.6 Locks Can Lead to Deadlock
1017
29.2.7 More Flexible Locking with “unique_lock”
1019
29.3 Other Synchronization Options
1021
29.3.1 Call Only Once with “once_flag” and “call_once”
1021
29.3.2 Locking with “recursive_mutex”
1023
29.4 In Its Own Storage with “thread_local”
1024
29.5 Waiting for Events with “condition_variable”
1025
29.5.1 “notify_all”
1028
29.5.2 Synchronize Output
1029
29.6 Waiting Once with “future”
1030
29.6.1 Launch Policies
1031
29.6.2 Wait Until a Certain Time
1032
29.6.3 Exception Handling with “future”
1035
29.6.4 “promise”
1037
29.7 Atomics
1040
29.7.1 Overview of the Operations
1042
29.7.2 Memory Order
1043
29.7.3 Example
1045
29.8 Coroutines
1046
29.8.1 Coroutines in the Compiler
1046
29.8.2 Generator
1047
29.8.3 Coroutines with “promise_type”
1048
29.9 Summary
1051
29.9.1 “<thread>” Header
1051
29.9.2 “<latch>” and “<barrier>” Headers
1051
29.9.3 “<mutex>” and “<shared mutex>” Headers
1052
29.9.4 “<condition variable>” Header
1052
29.9.5 “<future>” Header
1053
29.9.6 “<atomic>” Header
1053
29.9.7 “<coroutine>” Header
1053
30 Good Code, 7th Dan: Guidelines
1055
30.1 Guideline Support Library
1056
30.2 C++ Core Guidelines
1056
30.2.1 Motivation
1057
30.2.2 Type Safety
1058
30.2.3 Use RAII
1059
30.2.4 Class Hierarchies
1062
30.2.5 Generic Programming
1064
30.2.6 Do Not Be Confused by Anachronisms
1067
Appendices
1069
A Cheat Sheet
1069
B The Author
1073
Index
1075