1 The Basics 1
1.1 Introduction 1
1.2 Programs 1
1.3 Hello,World! 2
1.4 Functions 3
1.5 Types,Variables,and Arithmetic 5
1.6 Scope 8
1.7 Constants 8
1.8 Pointers,Arrays,and References 9
1.9 Tests 12
1.10 Advice 14
2 User-Defined Types 15
2.1 Introduction 15
2.2 Structures 16
2.3 Classes 17
2.4 Unions 19
2.5 Enumerations 20
2.6 Advice 21
3 Modularity 23
3.1 Introduction 23
3.2 Separate Compilation 24
3.3 Namespaces 26
3.4 Error Handling 27
3.5 Advice 31
4 Classes 33
4.1 Introduction 33
4.2 Concrete Types 34
4.3 Abstract Types 39
4.4 Virtual Functions 42
4.5 Class Hierarchies 42
4.6 Copy and Move 48
4.7 Advice 56
5 Templates 59
5.1 Introduction 59
5.2 Parameterized Types 59
5.3 Function Templates 62
5.4 Concepts and Generic Programming 62
5.5 Function Objects 64
5.6 Variadic Templates 66
5.7 Aliases 67
5.8 Template Compilation Model 68
5.9 Advice 68
6 Library Overview 71
6.1 Introduction 71
6.2 Standard-Library Components 72
6.3 Standard-Library Headers and Namespace 72
6.4 Advice 74
7 Strings and Regular Expressions 75
7.1 Introduction 75
7.2 Strings 75
7.3 Regular Expressions 78
7.4 Advice 84
8 I/O Streams 85
8.1 Introduction 85
8.2 Output 86
8.3 Input 87
8.4 I/O State 89
8.5 I/O of User-Defined Types 90
8.6 Formatting 91
8.7 File Streams 92
8.8 String Streams 92
8.9 Advice 93
9 Containers 95
9.1 Introduction 95
9.2 vector 96
9.3 list 100
9.4 map 101
9.5 unordered_map 102
9.6 Container Overview 103
9.7 Advice 104
10 Algorithms 107
10.1 Introduction 107
10.2 Use of Iterators 108
10.3 Iterator Types 111
10.4 Stream Iterators 112
10.5 Predicates 113
10.6 Algorithm Overview 114
10.7 Container Algorithms 115
10.8 Advice 115
11 Utilities 117
11.1 Introduction 117
11.2 Resource Management 117
11.3 Specialized Containers 121
11.4 Time 125
11.5 Function Adaptors 125
11.6 Type Functions 128
11.7 Advice 131
12 Numerics 133
12.1 Introduction 133
12.2 Mathematical Functions 134
12.3 Numerical Algorithms 135
12.4 Complex Numbers 135
12.5 Random Numbers 136
12.6 Vector Arithmetic 138
12.7 Numeric Limits 138
12.8 Advice 138
13 Concurrency 141
13.1 Introduction 141
13.2 Tasks and threads 142
13.3 Passing Arguments 143
13.4 Returning Results 144
13.5 Sharing Data 144
13.6 Waiting for Events 146
13.7 Communicating Tasks 147
13.8 Advice 151
14 History and Compatibility 153
14.1 History 153
14.2 C++11 Extensions 158
14.3 C/C++ Compatibility 161
14.4 Bibliography 166
14.5 Advice 168
Index 171