| Introduction |
|
xlvii | |
|
PART I INTRODUCTION TO PROFESSIONAL C++ |
|
|
|
Chapter 1 A Crash Course In C++ And The Standard Library |
|
|
3 | (84) |
|
|
|
4 | (1) |
|
The Obligatory "Hello, World" Program |
|
|
4 | (1) |
|
|
|
5 | (1) |
|
|
|
5 | (1) |
|
|
|
5 | (3) |
|
|
|
8 | (1) |
|
|
|
8 | (1) |
|
|
|
9 | (2) |
|
|
|
11 | (1) |
|
|
|
11 | (1) |
|
|
|
11 | (1) |
|
|
|
12 | (2) |
|
|
|
14 | (1) |
|
|
|
15 | (1) |
|
|
|
15 | (1) |
|
|
|
16 | (1) |
|
|
|
16 | (3) |
|
|
|
19 | (2) |
|
Old-Style Enumerated Types |
|
|
21 | (1) |
|
|
|
22 | (1) |
|
|
|
23 | (1) |
|
|
|
23 | (1) |
|
|
|
24 | (1) |
|
|
|
25 | (1) |
|
Logical Evaluation Operators |
|
|
26 | (1) |
|
|
|
27 | (1) |
|
|
|
28 | (2) |
|
Function Return Type Deduction |
|
|
30 | (1) |
|
|
|
30 | (1) |
|
|
|
30 | (1) |
|
|
|
30 | (1) |
|
|
|
31 | (1) |
|
|
|
31 | (1) |
|
|
|
32 | (1) |
|
|
|
32 | (1) |
|
[ [ Likely]] and [ [ unlikely]] |
|
|
33 | (1) |
|
|
|
33 | (2) |
|
|
|
35 | (1) |
|
|
|
36 | (1) |
|
|
|
36 | (1) |
|
|
|
37 | (1) |
|
|
|
38 | (1) |
|
|
|
38 | (1) |
|
|
|
38 | (1) |
|
|
|
39 | (1) |
|
|
|
39 | (1) |
|
|
|
39 | (1) |
|
|
|
40 | (1) |
|
|
|
40 | (1) |
|
C++ as an Object-Oriented Language |
|
|
41 | (1) |
|
|
|
41 | (3) |
|
|
|
44 | (1) |
|
|
|
44 | (1) |
|
|
|
45 | (3) |
|
|
|
48 | (1) |
|
Pointers and Dynamic Memory |
|
|
49 | (1) |
|
The Stack and the Free Store |
|
|
49 | (1) |
|
|
|
50 | (1) |
|
Dynamically Allocated Arrays |
|
|
51 | (1) |
|
|
|
52 | (1) |
|
|
|
53 | (1) |
|
Const as a Qualifier for a Type |
|
|
53 | (2) |
|
|
|
55 | (1) |
|
|
|
56 | (1) |
|
|
|
57 | (1) |
|
|
|
58 | (1) |
|
|
|
58 | (3) |
|
|
|
61 | (1) |
|
|
|
61 | (3) |
|
|
|
64 | (1) |
|
Deciding Between References and Pointers |
|
|
64 | (4) |
|
|
|
68 | (1) |
|
|
|
69 | (1) |
|
|
|
70 | (1) |
|
|
|
71 | (1) |
|
|
|
72 | (1) |
|
|
|
72 | (3) |
|
|
|
75 | (1) |
|
|
|
75 | (1) |
|
Your First Bigger C++ Program |
|
|
75 | (1) |
|
An Employee Records System |
|
|
76 | (1) |
|
|
|
76 | (1) |
|
|
|
76 | (2) |
|
|
|
78 | (1) |
|
|
|
79 | (1) |
|
|
|
80 | (1) |
|
|
|
80 | (1) |
|
|
|
81 | (1) |
|
|
|
82 | (1) |
|
|
|
82 | (3) |
|
|
|
85 | (1) |
|
|
|
85 | (1) |
|
|
|
85 | (2) |
|
Chapter 2 Working With Strings And String Views |
|
|
87 | (24) |
|
|
|
88 | (1) |
|
|
|
88 | (2) |
|
|
|
90 | (1) |
|
|
|
90 | (2) |
|
The C++ std::string Class |
|
|
92 | (1) |
|
What Is Wrong with C-Style Strings? |
|
|
92 | (1) |
|
|
|
92 | (3) |
|
|
|
95 | (1) |
|
CTAD with std::vector and Strings |
|
|
96 | (1) |
|
|
|
96 | (1) |
|
High-Level Numeric Conversions |
|
|
96 | (1) |
|
Low-Level Numeric Conversions |
|
|
97 | (3) |
|
The std::string view Class |
|
|
100 | (2) |
|
Std::string view and Temporary Strings |
|
|
102 | (1) |
|
Std::string view Literals |
|
|
102 | (1) |
|
|
|
102 | (1) |
|
|
|
103 | (1) |
|
|
|
104 | (1) |
|
|
|
104 | (1) |
|
|
|
105 | (1) |
|
|
|
105 | (1) |
|
|
|
105 | (1) |
|
|
|
106 | (1) |
|
|
|
107 | (1) |
|
|
|
107 | (1) |
|
|
|
107 | (1) |
|
|
|
107 | (3) |
|
|
|
110 | (1) |
|
|
|
110 | (1) |
|
Chapter 3 Coding With Style |
|
|
111 | (26) |
|
The Importance of Looking Good |
|
|
111 | (1) |
|
|
|
112 | (1) |
|
|
|
112 | (1) |
|
|
|
112 | (1) |
|
Reasons to Write Comments |
|
|
112 | (1) |
|
Commenting to Explain Usage |
|
|
112 | (3) |
|
Commenting to Explain Complicated Code |
|
|
115 | (1) |
|
Commenting to Convey Meta-information |
|
|
116 | (1) |
|
|
|
117 | (1) |
|
|
|
117 | (1) |
|
|
|
118 | (1) |
|
|
|
119 | (1) |
|
|
|
120 | (2) |
|
|
|
122 | (1) |
|
|
|
122 | (1) |
|
Decomposition Through Refactoring |
|
|
123 | (1) |
|
|
|
124 | (1) |
|
Decomposition in This Book |
|
|
124 | (1) |
|
|
|
124 | (1) |
|
|
|
124 | (1) |
|
|
|
125 | (1) |
|
|
|
125 | (1) |
|
|
|
126 | (1) |
|
|
|
126 | (1) |
|
|
|
127 | (1) |
|
|
|
127 | (1) |
|
|
|
127 | (1) |
|
Using Language Features with Style |
|
|
127 | (1) |
|
|
|
128 | (1) |
|
Use References Instead of Pointers |
|
|
128 | (1) |
|
|
|
129 | (1) |
|
|
|
129 | (1) |
|
The Curly Brace Alignment Debate |
|
|
130 | (1) |
|
Coming to Blows over Spaces and Parentheses |
|
|
131 | (1) |
|
Spaces, Tabs, and Line Breaks |
|
|
131 | (1) |
|
|
|
132 | (1) |
|
|
|
132 | (1) |
|
|
|
133 | (4) |
|
PART II PROFESSIONAL C++ SOFTWARE DESIGN |
|
|
|
Chapter 4 Designing Professional C++ Programs |
|
|
137 | (32) |
|
What Is Programming Design? |
|
|
138 | (1) |
|
The Importance of Programming Design |
|
|
139 | (2) |
|
|
|
141 | (1) |
|
Two Rules for Your Own C++ Designs |
|
|
142 | (1) |
|
|
|
142 | (1) |
|
Benefiting from Abstraction |
|
|
142 | (1) |
|
Incorporating Abstraction in Your Design |
|
|
143 | (1) |
|
|
|
144 | (1) |
|
|
|
144 | (1) |
|
|
|
145 | (1) |
|
|
|
146 | (1) |
|
|
|
146 | (1) |
|
Deciding Whether to Reuse Code or Write it Yourself |
|
|
147 | (1) |
|
Advantages to Reusing Code |
|
|
147 | (1) |
|
Disadvantages to Reusing Code |
|
|
148 | (1) |
|
Putting It Together to Make a Decision |
|
|
149 | (1) |
|
Guidelines for Choosing a Library to Reuse |
|
|
149 | (1) |
|
Understand the Capabilities and Limitations |
|
|
149 | (1) |
|
Understand the Learning Cost |
|
|
150 | (1) |
|
Understand the Performance |
|
|
150 | (3) |
|
Understand Platform Limitations |
|
|
153 | (1) |
|
|
|
153 | (1) |
|
Understand Support and Know Where to Find Help |
|
|
154 | (1) |
|
|
|
154 | (1) |
|
|
|
155 | (2) |
|
|
|
157 | (1) |
|
Designing a Chess Program |
|
|
157 | (1) |
|
|
|
158 | (1) |
|
|
|
158 | (1) |
|
Divide the Program into Subsystems |
|
|
158 | (2) |
|
|
|
160 | (1) |
|
Specify Class Hierarchies for Each Subsystem |
|
|
161 | (1) |
|
Specify Classes, Data Structures, Algorithms, and Patterns for Each Subsystem |
|
|
162 | (3) |
|
Specify Error Handling for Each Subsystem |
|
|
165 | (1) |
|
|
|
166 | (1) |
|
|
|
166 | (3) |
|
Chapter 5 Designing With Objects |
|
|
169 | (18) |
|
Am I Thinking Procedurally? |
|
|
170 | (1) |
|
The Object-Oriented Philosophy |
|
|
170 | (1) |
|
|
|
170 | (1) |
|
|
|
171 | (1) |
|
|
|
171 | (1) |
|
|
|
172 | (1) |
|
|
|
172 | (1) |
|
Living in a World of Classes |
|
|
173 | (1) |
|
|
|
173 | (1) |
|
|
|
174 | (1) |
|
|
|
175 | (1) |
|
|
|
175 | (1) |
|
The Is-a Relationship (Inheritance) |
|
|
176 | (1) |
|
|
|
177 | (1) |
|
|
|
178 | (1) |
|
The Fine Line Between Has-a and Is-a |
|
|
178 | (3) |
|
|
|
181 | (1) |
|
|
|
182 | (1) |
|
|
|
183 | (1) |
|
|
|
184 | (1) |
|
|
|
185 | (1) |
|
|
|
185 | (2) |
|
Chapter 6 Designing For Reuse |
|
|
187 | (24) |
|
|
|
188 | (1) |
|
How to Design Reusable Code |
|
|
189 | (1) |
|
|
|
189 | (2) |
|
Structure Your Code for Optimal Reuse |
|
|
191 | (1) |
|
Avoid Combining Unrelated or Logically Separate Concepts |
|
|
191 | (2) |
|
Use Templates for Generic Data Structures and Algorithms |
|
|
193 | (2) |
|
Provide Appropriate Checks and Safeguards |
|
|
195 | (1) |
|
|
|
196 | (2) |
|
|
|
198 | (1) |
|
|
|
198 | (1) |
|
|
|
199 | (1) |
|
Design Interfaces That Are Easy to Use |
|
|
200 | (4) |
|
Design General-Purpose Interfaces |
|
|
204 | (1) |
|
Reconciling Generality and Ease of Use |
|
|
205 | (1) |
|
Designing a Successful Abstraction |
|
|
205 | (1) |
|
|
|
206 | (1) |
|
|
|
207 | (1) |
|
|
|
207 | (4) |
|
PART III C++ CODING THE PROFESSIONAL WAY |
|
|
|
Chapter 7 Memory Management |
|
|
211 | (38) |
|
Working with Dynamic Memory |
|
|
212 | (1) |
|
|
|
212 | (1) |
|
Allocation and Deallocation |
|
|
213 | (1) |
|
|
|
213 | (1) |
|
What About My Good Friend malloc? |
|
|
214 | (1) |
|
When Memory Allocation Fails |
|
|
215 | (1) |
|
|
|
215 | (1) |
|
Arrays of Primitive Types |
|
|
215 | (3) |
|
|
|
218 | (1) |
|
|
|
218 | (1) |
|
|
|
219 | (4) |
|
|
|
223 | (1) |
|
A Mental Model for Pointers |
|
|
223 | (1) |
|
|
|
224 | (1) |
|
|
|
224 | (1) |
|
|
|
224 | (2) |
|
Not All Pointers Are Arrays! |
|
|
226 | (1) |
|
Low-Level Memory Operations |
|
|
227 | (1) |
|
|
|
227 | (1) |
|
|
|
228 | (1) |
|
|
|
228 | (1) |
|
|
|
229 | (1) |
|
|
|
229 | (1) |
|
Underallocating Data Buffers and Out-of-Bounds Memory Access |
|
|
229 | (2) |
|
|
|
231 | (1) |
|
Finding and Fixing Memory Leaks in Windows with Visual C++ |
|
|
232 | (1) |
|
Finding and Fixing Memory Leaks in Linux with Valgrind |
|
|
233 | (1) |
|
Double-Deletion and Invalid Pointers |
|
|
234 | (1) |
|
|
|
234 | (1) |
|
|
|
235 | (1) |
|
|
|
236 | (1) |
|
|
|
237 | (1) |
|
Unique ptr and C-Style Arrays |
|
|
238 | (1) |
|
|
|
239 | (1) |
|
|
|
239 | (1) |
|
Creating and Using shared ptrs |
|
|
239 | (2) |
|
The Need for Reference Counting |
|
|
241 | (1) |
|
|
|
242 | (1) |
|
|
|
242 | (1) |
|
|
|
243 | (1) |
|
|
|
244 | (1) |
|
|
|
244 | (1) |
|
|
|
244 | (1) |
|
The Old and Removed auto ptr |
|
|
245 | (1) |
|
|
|
246 | (1) |
|
|
|
246 | (3) |
|
Chapter 8 Gaining Proficiency With Classes And Objects |
|
|
249 | (34) |
|
Introducing the Spreadsheet Example |
|
|
250 | (1) |
|
|
|
250 | (1) |
|
|
|
250 | (1) |
|
|
|
251 | (1) |
|
|
|
251 | (1) |
|
|
|
252 | (1) |
|
In-Class Member Initializers |
|
|
253 | (1) |
|
|
|
253 | (1) |
|
|
|
254 | (1) |
|
|
|
254 | (1) |
|
|
|
255 | (2) |
|
|
|
257 | (1) |
|
|
|
257 | (1) |
|
Objects on the Free Store |
|
|
257 | (1) |
|
Understanding Object Life Cycles |
|
|
258 | (1) |
|
|
|
258 | (1) |
|
|
|
259 | (1) |
|
|
|
260 | (1) |
|
Providing Multiple Constructors |
|
|
260 | (1) |
|
|
|
261 | (4) |
|
|
|
265 | (4) |
|
|
|
269 | (2) |
|
Initializer-List Constructors |
|
|
271 | (2) |
|
|
|
273 | (1) |
|
Converting Constructors and Explicit Constructors |
|
|
273 | (2) |
|
Summary of Compiler-Generated Constructors |
|
|
275 | (1) |
|
|
|
276 | (1) |
|
|
|
277 | (1) |
|
Declaring an Assignment Operator |
|
|
278 | (1) |
|
Defining an Assignment Operator |
|
|
278 | (2) |
|
Explicitly Defaulted and Deleted Assignment Operator |
|
|
280 | (1) |
|
Compiler-Generated Copy Constructor and Copy Assignment Operator |
|
|
280 | (1) |
|
Distinguishing Copying from Assignment |
|
|
280 | (1) |
|
|
|
280 | (1) |
|
Copy Constructors and Object Members |
|
|
281 | (1) |
|
|
|
282 | (1) |
|
|
|
282 | (1) |
|
Chapter 9 Mastering Classes And Objects |
|
|
283 | (54) |
|
|
|
284 | (1) |
|
Dynamic Memory Allocation in Objects |
|
|
285 | (1) |
|
|
|
285 | (3) |
|
Freeing Memory with Destructors |
|
|
288 | (1) |
|
Handling Copying and Assignment |
|
|
289 | (2) |
|
The Spreadsheet Copy Constructor |
|
|
291 | (1) |
|
The Spreadsheet Assignment Operator |
|
|
291 | (3) |
|
Disallowing Assignment and Pass-by-Value |
|
|
294 | (1) |
|
Handling Moving with Move Semantics |
|
|
295 | (1) |
|
|
|
295 | (2) |
|
Implementing Move Semantics |
|
|
297 | (4) |
|
Testing the Spreadsheet Move Operations |
|
|
301 | (2) |
|
Implementing a Swap Function with Move Semantics |
|
|
303 | (1) |
|
Using std::move() in Return Statements |
|
|
303 | (1) |
|
Optimal Way to Pass Arguments to Functions |
|
|
304 | (1) |
|
|
|
305 | (1) |
|
|
|
306 | (1) |
|
|
|
306 | (1) |
|
|
|
307 | (1) |
|
|
|
308 | (1) |
|
|
|
308 | (1) |
|
Overloading Based on const |
|
|
309 | (1) |
|
Explicitly Deleting Overloads |
|
|
310 | (1) |
|
|
|
310 | (1) |
|
|
|
311 | (2) |
|
|
|
313 | (1) |
|
Different Kinds of Data Members |
|
|
314 | (1) |
|
|
|
314 | (1) |
|
|
|
314 | (1) |
|
Accessing static Data Members within Class Methods |
|
|
315 | (1) |
|
Accessing static Data Members Outside Methods |
|
|
316 | (1) |
|
Const static Data Members |
|
|
316 | (1) |
|
|
|
317 | (1) |
|
|
|
318 | (1) |
|
Enumerated Types Inside Classes |
|
|
319 | (1) |
|
|
|
320 | (1) |
|
Example: Implementing Addition for SpreadsheetCells |
|
|
320 | (1) |
|
First Attempt: The add Method |
|
|
320 | (1) |
|
Second Attempt: Overloaded operator+ as a Method |
|
|
321 | (1) |
|
Third Attempt: Global operator+ |
|
|
322 | (2) |
|
Overloading Arithmetic Operators |
|
|
324 | (1) |
|
Overloading the Arithmetic Shorthand Operators |
|
|
324 | (1) |
|
Overloading Comparison Operators |
|
|
325 | (3) |
|
Compiler-Generated Comparison Operators |
|
|
328 | (2) |
|
Building Types with Operator Overloading |
|
|
330 | (1) |
|
Building Stable Interfaces |
|
|
330 | (1) |
|
Using Interface and Implementation Classes |
|
|
330 | (4) |
|
|
|
334 | (1) |
|
|
|
335 | (2) |
|
Chapter 10 Discovering Inheritance Techniques |
|
|
337 | (60) |
|
Building Classes with Inheritance |
|
|
338 | (1) |
|
|
|
338 | (1) |
|
A Client's View of Inheritance |
|
|
339 | (1) |
|
A Derived Class's View of Inheritance |
|
|
340 | (1) |
|
|
|
341 | (1) |
|
|
|
342 | (1) |
|
|
|
342 | (1) |
|
Syntax for Overriding a Method |
|
|
342 | (1) |
|
A Client's View of Overridden Methods |
|
|
343 | (1) |
|
|
|
344 | (2) |
|
|
|
346 | (4) |
|
|
|
350 | (1) |
|
|
|
350 | (1) |
|
The WeatherPrediction Class |
|
|
350 | (1) |
|
Adding Functionality in a Derived Class |
|
|
351 | (1) |
|
Replacing Functionality in a Derived Class |
|
|
352 | (1) |
|
|
|
353 | (1) |
|
|
|
353 | (2) |
|
|
|
355 | (1) |
|
Referring to Parent Names |
|
|
356 | (2) |
|
|
|
358 | (2) |
|
Inheritance for Polymorphism |
|
|
360 | (1) |
|
Return of the Spreadsheet |
|
|
360 | (1) |
|
Designing the Polymorphic Spreadsheet Cell |
|
|
360 | (1) |
|
The SpreadsheetCell Base Class |
|
|
361 | (1) |
|
|
|
361 | (1) |
|
Pure Virtual Methods and Abstract Base Classes |
|
|
362 | (1) |
|
The Individual Derived Classes |
|
|
363 | (1) |
|
StringSpreadsheetCell Class Definition |
|
|
363 | (1) |
|
StringSpreadsheetCell Implementation |
|
|
363 | (1) |
|
DoubleSpreadsheetCell Class Definition and Implementation |
|
|
364 | (1) |
|
|
|
364 | (1) |
|
|
|
365 | (2) |
|
|
|
367 | (1) |
|
Inheriting from Multiple Classes |
|
|
367 | (1) |
|
Naming Collisions and Ambiguous Base Classes |
|
|
368 | (1) |
|
|
|
368 | (1) |
|
|
|
369 | (2) |
|
Uses for Multiple Inheritance |
|
|
371 | (1) |
|
Interesting and Obscure Inheritance Issues |
|
|
371 | (1) |
|
Changing the Overridden Method's Return Type |
|
|
371 | (2) |
|
Adding Overloads of Virtual Base Class Methods to Derived Classes |
|
|
373 | (1) |
|
|
|
374 | (1) |
|
Hiding of Inherited Constructors |
|
|
375 | (1) |
|
Inherited Constructors and Multiple Inheritance |
|
|
376 | (1) |
|
Initialization of Data Members |
|
|
377 | (1) |
|
Special Cases in Overriding Methods |
|
|
378 | (1) |
|
The Base Class Method Is static |
|
|
378 | (1) |
|
The Base Class Method Is Overloaded |
|
|
379 | (1) |
|
The Base Class Method Is private |
|
|
380 | (2) |
|
The Base Class Method Has Default Arguments |
|
|
382 | (1) |
|
The Base Class Method Has a Different Access Specification |
|
|
383 | (2) |
|
Copy Constructors and Assignment Operators in Derived Classes |
|
|
385 | (1) |
|
|
|
386 | (2) |
|
|
|
388 | (1) |
|
|
|
389 | (1) |
|
|
|
390 | (1) |
|
|
|
390 | (1) |
|
|
|
391 | (1) |
|
|
|
392 | (1) |
|
|
|
393 | (1) |
|
|
|
394 | (1) |
|
|
|
394 | (1) |
|
|
|
395 | (2) |
|
|
|
397 | (24) |
|
|
|
397 | (2) |
|
|
|
399 | (2) |
|
Module Implementation Files |
|
|
401 | (1) |
|
Splitting Interface from Implementation |
|
|
402 | (1) |
|
Visibility vs. Reachability |
|
|
403 | (1) |
|
|
|
404 | (1) |
|
|
|
405 | (2) |
|
Implementation Partitions |
|
|
407 | (1) |
|
|
|
408 | (1) |
|
|
|
408 | (1) |
|
|
|
409 | (1) |
|
|
|
409 | (1) |
|
Querying Existence of Headers |
|
|
410 | (1) |
|
Feature Test Macros for Core Language Features |
|
|
410 | (1) |
|
|
|
411 | (1) |
|
Static Data Members and Methods |
|
|
411 | (1) |
|
|
|
411 | (2) |
|
|
|
413 | (1) |
|
Static Variables in Functions |
|
|
414 | (1) |
|
Order of Initialization of Nonlocal Variables |
|
|
415 | (1) |
|
Order of Destruction of Nonlocal Variables |
|
|
415 | (1) |
|
|
|
415 | (1) |
|
Variable-Length Argument Lists |
|
|
415 | (1) |
|
|
|
416 | (1) |
|
Why You Shouldn't Use C-Style Variable-Length Argument Lists |
|
|
417 | (1) |
|
|
|
417 | (2) |
|
|
|
419 | (1) |
|
|
|
419 | (2) |
|
Chapter 12 Writing Generic Code With Templates |
|
|
421 | (44) |
|
|
|
422 | (1) |
|
|
|
422 | (1) |
|
|
|
423 | (1) |
|
|
|
423 | (3) |
|
|
|
426 | (4) |
|
|
|
430 | (1) |
|
How the Compiler Processes Templates |
|
|
431 | (1) |
|
|
|
431 | (1) |
|
Template Requirements on Types |
|
|
432 | (1) |
|
Distributing Template Code Between Files |
|
|
432 | (1) |
|
Method Definitions in Same File as Class Template Definition |
|
|
433 | (1) |
|
Method Definitions in Separate File |
|
|
433 | (1) |
|
|
|
433 | (1) |
|
Non-type Template Parameters |
|
|
434 | (2) |
|
Default Values for Type Parameters |
|
|
436 | (1) |
|
Class Template Argument Deduction |
|
|
436 | (2) |
|
|
|
438 | (2) |
|
Method Templates with Non-type Parameters |
|
|
440 | (2) |
|
Class Template Specialization |
|
|
442 | (3) |
|
Deriving from Class Templates |
|
|
445 | (1) |
|
Inheritance vs. Specialization |
|
|
446 | (1) |
|
|
|
447 | (1) |
|
|
|
447 | (2) |
|
Function Template Overloading |
|
|
449 | (1) |
|
Friend Function Templates of Class Templates |
|
|
449 | (2) |
|
More on Template Parameter Deduction |
|
|
451 | (1) |
|
Return Type of Function Templates |
|
|
451 | (2) |
|
Abbreviated Function Template Syntax |
|
|
453 | (1) |
|
|
|
454 | (1) |
|
|
|
454 | (1) |
|
|
|
455 | (1) |
|
|
|
455 | (1) |
|
|
|
455 | (2) |
|
Combining Concept Expressions |
|
|
457 | (1) |
|
Predefined Standard Concepts |
|
|
457 | (1) |
|
|
|
458 | (1) |
|
Type Constraints and Function Templates |
|
|
458 | (2) |
|
|
|
460 | (1) |
|
Type Constraints and Class Templates |
|
|
461 | (1) |
|
Type Constraints and Class Methods |
|
|
461 | (1) |
|
Type Constraints and Template Specialization |
|
|
462 | (1) |
|
|
|
463 | (1) |
|
|
|
463 | (2) |
|
Chapter 13 Demystifying C++I/O |
|
|
465 | (30) |
|
|
|
466 | (1) |
|
What Is a Stream, Anyway? |
|
|
466 | (1) |
|
Stream Sources and Destinations |
|
|
467 | (1) |
|
|
|
468 | (1) |
|
|
|
468 | (1) |
|
Methods of Output Streams |
|
|
469 | (1) |
|
|
|
470 | (1) |
|
|
|
471 | (2) |
|
|
|
473 | (1) |
|
|
|
473 | (2) |
|
|
|
475 | (1) |
|
|
|
476 | (4) |
|
|
|
480 | (1) |
|
Input and Output with Objects |
|
|
481 | (1) |
|
|
|
482 | (1) |
|
|
|
482 | (2) |
|
|
|
484 | (1) |
|
Text Mode vs. Binary Mode |
|
|
485 | (1) |
|
Jumping Around with seek() and tell() |
|
|
485 | (2) |
|
|
|
487 | (1) |
|
|
|
488 | (2) |
|
Filesystem Support Library |
|
|
490 | (1) |
|
|
|
490 | (1) |
|
|
|
491 | (1) |
|
|
|
492 | (1) |
|
|
|
492 | (1) |
|
|
|
493 | (1) |
|
|
|
493 | (2) |
|
Chapter 14 Handling Errors |
|
|
495 | (40) |
|
|
|
496 | (1) |
|
What Are Exceptions, Anyway? |
|
|
496 | (1) |
|
Why Exceptions in C++Are a Good Thing |
|
|
496 | (2) |
|
|
|
498 | (1) |
|
|
|
498 | (1) |
|
Throwing and Catching Exceptions |
|
|
499 | (2) |
|
|
|
501 | (1) |
|
Catching Exception Objects as Reference-to-const |
|
|
502 | (1) |
|
Throwing and Catching Multiple Exceptions |
|
|
503 | (2) |
|
|
|
505 | (1) |
|
|
|
505 | (1) |
|
|
|
505 | (2) |
|
|
|
507 | (1) |
|
Noexcept(expression) Specifier |
|
|
508 | (1) |
|
Noexcept(expression) Operator |
|
|
508 | (1) |
|
|
|
508 | (1) |
|
Exceptions and Polymorphism |
|
|
509 | (1) |
|
The Standard Exception Hierarchy |
|
|
509 | (1) |
|
Catching Exceptions in a Class Hierarchy |
|
|
510 | (2) |
|
Writing Your Own Exception Classes |
|
|
512 | (2) |
|
|
|
514 | (3) |
|
|
|
517 | (2) |
|
|
|
519 | (1) |
|
Stack Unwinding and Cleanup |
|
|
520 | (1) |
|
|
|
521 | (1) |
|
Catch, Cleanup, and Rethrow |
|
|
522 | (1) |
|
Common Error-Handling Issues |
|
|
523 | (1) |
|
|
|
523 | (1) |
|
|
|
524 | (1) |
|
Customizing Memory Allocation Failure Behavior |
|
|
524 | (2) |
|
|
|
526 | (2) |
|
Function-Try-Blocks for Constructors |
|
|
528 | (3) |
|
|
|
531 | (1) |
|
|
|
531 | (1) |
|
|
|
532 | (3) |
|
Chapter 15 Overloading C++ Operators |
|
|
535 | (38) |
|
Overview of Operator Overloading |
|
|
536 | (1) |
|
|
|
536 | (1) |
|
Limitations to Operator Overloading |
|
|
536 | (1) |
|
Choices in Operator Overloading |
|
|
537 | (1) |
|
Method or Global Function |
|
|
537 | (1) |
|
|
|
538 | (1) |
|
|
|
538 | (1) |
|
|
|
539 | (1) |
|
Operators You Shouldn't Overload |
|
|
539 | (1) |
|
Summary of Overloadable Operators |
|
|
540 | (4) |
|
|
|
544 | (1) |
|
Precedence and Associativity |
|
|
545 | (1) |
|
|
|
546 | (1) |
|
Overloading the Arithmetic Operators |
|
|
547 | (1) |
|
Overloading Unary Minus and Unary Plus |
|
|
547 | (1) |
|
Overloading Increment and Decrement |
|
|
547 | (1) |
|
Overloading the Bitwise and Binary Logical Operators |
|
|
548 | (1) |
|
Overloading the Insertion and Extraction Operators |
|
|
549 | (1) |
|
Overloading the Subscripting Operator |
|
|
550 | (3) |
|
Providing Read-Only Access with operatorfj |
|
|
553 | (2) |
|
Non-integral Array Indices |
|
|
555 | (1) |
|
Overloading the Function Call Operator |
|
|
555 | (2) |
|
Overloading the Dereferencing Operators |
|
|
557 | (1) |
|
|
|
558 | (1) |
|
|
|
558 | (1) |
|
What in the World Are operator.* and operator->*? |
|
|
559 | (1) |
|
Writing Conversion Operators |
|
|
559 | (1) |
|
|
|
560 | (1) |
|
Solving Ambiguity Problems with Explicit Conversion Operators |
|
|
561 | (1) |
|
Conversions for Boolean Expressions |
|
|
561 | (2) |
|
Overloading the Memory Allocation and Deallocation Operators |
|
|
563 | (1) |
|
How new and delete Really Work |
|
|
564 | (1) |
|
The New-Expression and operator new |
|
|
564 | (1) |
|
The Delete-Expression and operator delete |
|
|
565 | (1) |
|
Overloading operator new and operator delete |
|
|
565 | (3) |
|
Explicitly Deleting/Defaulting operator new and operator delete |
|
|
568 | (1) |
|
Overloading operator new and operator delete with Extra Parameters |
|
|
568 | (1) |
|
Overloading operator delete with Size of Memory as Parameter |
|
|
569 | (1) |
|
Overloading User-Defined Literal Operators |
|
|
570 | (1) |
|
Cooked-Mode Literal Operator |
|
|
570 | (1) |
|
Raw-Mode Literal Operator |
|
|
571 | (1) |
|
Standard User-Defined Literals |
|
|
571 | (1) |
|
|
|
572 | (1) |
|
|
|
572 | (1) |
|
Chapter 16 Overview Of The C++ Standard Library |
|
|
573 | (30) |
|
|
|
574 | (1) |
|
|
|
574 | (1) |
|
Use of Operator Overloading |
|
|
575 | (1) |
|
Overview of the C++ Standard Library |
|
|
575 | (1) |
|
|
|
575 | (1) |
|
|
|
576 | (1) |
|
|
|
576 | (1) |
|
|
|
576 | (1) |
|
|
|
576 | (1) |
|
|
|
577 | (2) |
|
|
|
579 | (1) |
|
|
|
579 | (1) |
|
|
|
579 | (1) |
|
|
|
579 | (1) |
|
|
|
580 | (1) |
|
|
|
580 | (1) |
|
|
|
580 | (1) |
|
|
|
580 | (1) |
|
|
|
581 | (1) |
|
|
|
581 | (1) |
|
Standard Library Feature Test Macros |
|
|
581 | (1) |
|
|
|
582 | (1) |
|
|
|
582 | (1) |
|
|
|
582 | (1) |
|
|
|
583 | (1) |
|
|
|
584 | (1) |
|
|
|
584 | (1) |
|
|
|
584 | (1) |
|
|
|
584 | (1) |
|
|
|
585 | (1) |
|
|
|
585 | (1) |
|
|
|
585 | (1) |
|
|
|
586 | (1) |
|
|
|
586 | (1) |
|
|
|
587 | (1) |
|
Unordered Associative Containers/Hash Tables |
|
|
587 | (1) |
|
|
|
588 | (1) |
|
Summary of Standard Library Containers |
|
|
588 | (3) |
|
|
|
591 | (1) |
|
Nonmodifying Sequence Algorithms |
|
|
591 | (2) |
|
Modifying Sequence Algorithms |
|
|
593 | (2) |
|
|
|
595 | (1) |
|
|
|
595 | (1) |
|
|
|
595 | (1) |
|
|
|
596 | (1) |
|
|
|
597 | (1) |
|
|
|
597 | (1) |
|
|
|
598 | (1) |
|
Minimum/Maximum Algorithms |
|
|
598 | (1) |
|
Numerical Processing Algorithms |
|
|
599 | (1) |
|
|
|
600 | (1) |
|
|
|
600 | (1) |
|
|
|
601 | (1) |
|
What's Missing from the Standard Library |
|
|
601 | (1) |
|
|
|
601 | (1) |
|
|
|
601 | (2) |
|
Chapter 17 Understanding Iterators And The Ranges Library |
|
|
603 | (24) |
|
|
|
604 | (2) |
|
Getting Iterators for Containers |
|
|
606 | (2) |
|
|
|
608 | (1) |
|
|
|
609 | (1) |
|
|
|
610 | (1) |
|
|
|
610 | (1) |
|
|
|
611 | (1) |
|
|
|
612 | (1) |
|
|
|
612 | (2) |
|
|
|
614 | (1) |
|
|
|
615 | (1) |
|
|
|
616 | (1) |
|
|
|
617 | (1) |
|
|
|
618 | (1) |
|
|
|
619 | (3) |
|
Modifying Elements Through a View |
|
|
622 | (1) |
|
|
|
623 | (1) |
|
|
|
623 | (2) |
|
|
|
625 | (1) |
|
|
|
625 | (1) |
|
|
|
626 | (1) |
|
Chapter 18 Standard Library Containers |
|
|
627 | (72) |
|
|
|
628 | (1) |
|
|
|
628 | (2) |
|
Exceptions and Error Checking |
|
|
630 | (1) |
|
|
|
631 | (1) |
|
|
|
631 | (1) |
|
|
|
631 | (2) |
|
|
|
633 | (13) |
|
|
|
646 | (1) |
|
Vector Example: A Round-Robin Class |
|
|
647 | (5) |
|
The vector<bool> Specialization |
|
|
652 | (1) |
|
|
|
653 | (1) |
|
|
|
653 | (1) |
|
|
|
653 | (1) |
|
|
|
654 | (1) |
|
Adding and Removing Elements |
|
|
654 | (1) |
|
|
|
654 | (1) |
|
|
|
654 | (2) |
|
List Example: Determining Enrollment |
|
|
656 | (1) |
|
|
|
657 | (3) |
|
|
|
660 | (1) |
|
|
|
661 | (2) |
|
|
|
663 | (1) |
|
|
|
663 | (1) |
|
|
|
663 | (1) |
|
Queue Example: A Network Packet Buffer |
|
|
664 | (2) |
|
|
|
666 | (1) |
|
Priority queue Operations |
|
|
666 | (1) |
|
Priority queue Example: An Error Correlator |
|
|
667 | (1) |
|
|
|
668 | (1) |
|
|
|
668 | (1) |
|
Stack Example: Revised Error Correlator |
|
|
669 | (1) |
|
Ordered Associative Containers |
|
|
669 | (1) |
|
|
|
669 | (1) |
|
|
|
670 | (1) |
|
|
|
670 | (1) |
|
|
|
671 | (3) |
|
|
|
674 | (1) |
|
|
|
675 | (1) |
|
|
|
675 | (1) |
|
|
|
676 | (1) |
|
Map Example: Bank Account |
|
|
676 | (3) |
|
|
|
679 | (1) |
|
Multimap Example: Buddy Lists |
|
|
680 | (2) |
|
|
|
682 | (1) |
|
Set Example: Access Control List |
|
|
682 | (2) |
|
|
|
684 | (1) |
|
Unordered Associative Containers or Hash Tables |
|
|
684 | (1) |
|
|
|
684 | (2) |
|
|
|
686 | (3) |
|
Unordered map Example: Phone Book |
|
|
689 | (1) |
|
|
|
690 | (1) |
|
Unordered set/unordered multiset |
|
|
691 | (1) |
|
|
|
691 | (1) |
|
|
|
691 | (1) |
|
|
|
692 | (1) |
|
|
|
693 | (1) |
|
|
|
693 | (1) |
|
|
|
693 | (1) |
|
|
|
694 | (1) |
|
Bitset Example: Representing Cable Channels |
|
|
694 | (3) |
|
|
|
697 | (1) |
|
|
|
698 | (1) |
|
Chapter 19 Function Pointers, Function Objects, And Lambda Expressions |
|
|
699 | (26) |
|
|
|
700 | (2) |
|
Pointers to Methods (and Data Members) |
|
|
702 | (1) |
|
|
|
703 | (2) |
|
|
|
705 | (1) |
|
Writing Your First Function Object |
|
|
705 | (1) |
|
Function Objects in the Standard Library |
|
|
706 | (1) |
|
Arithmetic Function Objects |
|
|
706 | (1) |
|
Comparison Function Objects |
|
|
707 | (2) |
|
|
|
709 | (1) |
|
|
|
709 | (1) |
|
|
|
709 | (4) |
|
|
|
713 | (1) |
|
|
|
713 | (5) |
|
Lambda Expressions as Parameters |
|
|
718 | (1) |
|
Generic Lambda Expressions |
|
|
719 | (1) |
|
Lambda Capture Expressions |
|
|
719 | (1) |
|
Templated Lambda Expressions |
|
|
720 | (1) |
|
Lambda Expressions as Return Type |
|
|
721 | (1) |
|
Lambda Expressions in Unevaluated Contexts |
|
|
722 | (1) |
|
Default Construction, Copying, and Assigning |
|
|
722 | (1) |
|
|
|
722 | (1) |
|
|
|
723 | (1) |
|
|
|
723 | (2) |
|
Chapter 20 Mastering Standard Library Algorithms |
|
|
725 | (38) |
|
|
|
726 | (1) |
|
The find and find if Algorithms |
|
|
726 | (3) |
|
|
|
729 | (1) |
|
Move Semantics with Algorithms |
|
|
730 | (1) |
|
|
|
730 | (1) |
|
|
|
731 | (1) |
|
Non-modifying Sequence Algorithms |
|
|
731 | (1) |
|
|
|
731 | (2) |
|
|
|
733 | (1) |
|
|
|
733 | (3) |
|
|
|
736 | (1) |
|
Modifying Sequence Algorithms |
|
|
737 | (1) |
|
|
|
737 | (1) |
|
|
|
738 | (1) |
|
|
|
739 | (1) |
|
|
|
740 | (2) |
|
|
|
742 | (1) |
|
|
|
742 | (1) |
|
|
|
743 | (1) |
|
|
|
744 | (1) |
|
|
|
745 | (1) |
|
|
|
745 | (1) |
|
|
|
746 | (1) |
|
|
|
746 | (1) |
|
|
|
747 | (1) |
|
|
|
747 | (2) |
|
|
|
749 | (1) |
|
|
|
749 | (1) |
|
|
|
750 | (1) |
|
|
|
751 | (1) |
|
|
|
752 | (3) |
|
Minimum/Maximum Algorithms |
|
|
755 | (1) |
|
|
|
756 | (2) |
|
|
|
758 | (1) |
|
Numerical Processing Algorithms |
|
|
758 | (1) |
|
|
|
759 | (1) |
|
|
|
759 | (1) |
|
|
|
760 | (1) |
|
|
|
761 | (1) |
|
|
|
761 | (2) |
|
Chapter 21 String Localization And Regular Expressions |
|
|
763 | (30) |
|
|
|
763 | (1) |
|
|
|
764 | (1) |
|
Localizing String Literals |
|
|
764 | (1) |
|
Non-Western Character Sets |
|
|
765 | (2) |
|
|
|
767 | (1) |
|
|
|
767 | (2) |
|
|
|
769 | (1) |
|
|
|
769 | (1) |
|
|
|
769 | (1) |
|
|
|
770 | (1) |
|
|
|
771 | (1) |
|
|
|
772 | (1) |
|
|
|
773 | (1) |
|
|
|
773 | (1) |
|
|
|
773 | (1) |
|
|
|
773 | (1) |
|
|
|
774 | (1) |
|
|
|
774 | (1) |
|
|
|
775 | (1) |
|
|
|
775 | (2) |
|
|
|
777 | (1) |
|
|
|
778 | (1) |
|
|
|
778 | (1) |
|
Regular Expressions and Raw String Literals |
|
|
778 | (1) |
|
Common Regular Expressions |
|
|
779 | (1) |
|
|
|
779 | (2) |
|
|
|
781 | (1) |
|
|
|
781 | (2) |
|
|
|
783 | (1) |
|
|
|
784 | (1) |
|
|
|
784 | (1) |
|
|
|
785 | (1) |
|
|
|
785 | (1) |
|
Regex token iterator Examples |
|
|
786 | (2) |
|
|
|
788 | (1) |
|
|
|
789 | (1) |
|
|
|
790 | (1) |
|
|
|
791 | (2) |
|
Chapter 22 Date And Time Utilities |
|
|
793 | (16) |
|
Compile-Time Rational Numbers |
|
|
794 | (2) |
|
|
|
796 | (5) |
|
|
|
801 | (1) |
|
|
|
802 | (2) |
|
|
|
804 | (3) |
|
|
|
807 | (1) |
|
|
|
808 | (1) |
|
|
|
808 | (1) |
|
Chapter 23 Random Number Facilities |
|
|
809 | (12) |
|
C-Style Random Number Generation |
|
|
810 | (1) |
|
|
|
811 | (2) |
|
Random Number Engine Adapters |
|
|
813 | (1) |
|
Predefined Engines and Engine Adapters |
|
|
813 | (1) |
|
Generating Random Numbers |
|
|
814 | (2) |
|
Random Number Distributions |
|
|
816 | (3) |
|
|
|
819 | (1) |
|
|
|
819 | (2) |
|
Chapter 24 Additional Library Utilities |
|
|
821 | (12) |
|
|
|
821 | (1) |
|
|
|
821 | (2) |
|
|
|
823 | (1) |
|
|
|
824 | (2) |
|
|
|
826 | (1) |
|
|
|
827 | (1) |
|
|
|
827 | (1) |
|
|
|
828 | (1) |
|
|
|
828 | (1) |
|
|
|
829 | (1) |
|
|
|
829 | (1) |
|
|
|
829 | (1) |
|
|
|
830 | (3) |
|
PART IV MASTERING ADVANCED FEATURES OF C++ |
|
|
|
Chapter 25 Customizing And Extending The Standard Library |
|
|
833 | (44) |
|
|
|
834 | (1) |
|
Extending the Standard Library |
|
|
835 | (1) |
|
Why Extend the Standard Library? |
|
|
835 | (1) |
|
Writing a Standard Library Algorithm |
|
|
836 | (1) |
|
|
|
836 | (1) |
|
Writing a Standard Library Container |
|
|
837 | (1) |
|
|
|
837 | (11) |
|
Making directed graph a Standard Library Container |
|
|
848 | (18) |
|
Adding Support for Allocators |
|
|
866 | (5) |
|
|
|
871 | (1) |
|
Additional Standard Library-Like Functionality |
|
|
872 | (2) |
|
|
|
874 | (1) |
|
|
|
874 | (1) |
|
|
|
875 | (1) |
|
|
|
875 | (2) |
|
Chapter 26 Advanced Templates |
|
|
877 | (38) |
|
More About Template Parameters |
|
|
878 | (1) |
|
More About Template Type Parameters |
|
|
878 | (2) |
|
Introducing Template Template Parameters |
|
|
880 | (2) |
|
More About Non-type Template Parameters |
|
|
882 | (2) |
|
Class Template Partial Specialization |
|
|
884 | (4) |
|
Emulating Function Partial Specialization with Overloading |
|
|
888 | (1) |
|
|
|
889 | (1) |
|
An N-Dimensional Grid: First Attempt |
|
|
889 | (1) |
|
A Real N-Dimensional Grid |
|
|
890 | (2) |
|
|
|
892 | (1) |
|
Type-Safe Variable-Length Argument Lists |
|
|
893 | (2) |
|
Variable Number of Mixin Classes |
|
|
895 | (1) |
|
|
|
896 | (2) |
|
|
|
898 | (1) |
|
Factorial at Compile Time |
|
|
898 | (1) |
|
|
|
899 | (1) |
|
|
|
900 | (2) |
|
|
|
902 | (1) |
|
Using a Compile-Time Integer Sequence with Folding |
|
|
903 | (1) |
|
|
|
903 | (2) |
|
|
|
905 | (2) |
|
|
|
907 | (1) |
|
Using the conditional Type Trait |
|
|
907 | (2) |
|
|
|
909 | (1) |
|
Using constexpr if to Simplify enable if Constructs |
|
|
910 | (2) |
|
|
|
912 | (1) |
|
|
|
912 | (1) |
|
Metaprogramming Conclusion |
|
|
913 | (1) |
|
|
|
913 | (1) |
|
|
|
913 | (2) |
|
Chapter 27 Multithreaded Programming With C++ |
|
|
915 | (56) |
|
|
|
916 | (2) |
|
|
|
918 | (1) |
|
|
|
919 | (1) |
|
|
|
919 | (1) |
|
|
|
920 | (1) |
|
|
|
921 | (1) |
|
Thread with Function Pointer |
|
|
921 | (1) |
|
Thread with Function Object |
|
|
922 | (2) |
|
|
|
924 | (1) |
|
Thread with Member Function |
|
|
924 | (1) |
|
|
|
924 | (1) |
|
|
|
925 | (1) |
|
Automatically Joining Threads |
|
|
925 | (1) |
|
Retrieving Results from Threads |
|
|
926 | (1) |
|
Copying and Rethrowing Exceptions |
|
|
926 | (3) |
|
Atomic Operations Library |
|
|
929 | (2) |
|
|
|
931 | (1) |
|
|
|
932 | (1) |
|
|
|
932 | (1) |
|
|
|
933 | (2) |
|
Waiting on Atomic Variables |
|
|
935 | (1) |
|
|
|
936 | (1) |
|
|
|
936 | (1) |
|
|
|
936 | (1) |
|
|
|
937 | (2) |
|
|
|
939 | (1) |
|
|
|
939 | (1) |
|
|
|
939 | (1) |
|
|
|
940 | (1) |
|
|
|
941 | (1) |
|
Acquiring Multiple Locks at Once |
|
|
941 | (1) |
|
|
|
942 | (1) |
|
|
|
942 | (1) |
|
Examples Using Mutual Exclusion Objects |
|
|
943 | (1) |
|
Thread-Safe Writing to Streams |
|
|
943 | (2) |
|
|
|
945 | (1) |
|
|
|
946 | (1) |
|
|
|
947 | (1) |
|
|
|
948 | (1) |
|
Using Condition Variables |
|
|
949 | (1) |
|
|
|
950 | (1) |
|
|
|
951 | (1) |
|
|
|
951 | (1) |
|
|
|
952 | (1) |
|
Std::promise and std::future |
|
|
953 | (1) |
|
|
|
954 | (1) |
|
|
|
955 | (1) |
|
|
|
956 | (1) |
|
|
|
956 | (2) |
|
Example: Multithreaded Logger Class |
|
|
958 | (4) |
|
|
|
962 | (1) |
|
|
|
963 | (2) |
|
Threading Design and Best Practices |
|
|
965 | (1) |
|
|
|
966 | (1) |
|
|
|
966 | (5) |
|
PART V C++ SOFTEARE ENGINEERING |
|
|
|
Chapter 28 Maximizing Software Engineering Methods |
|
|
971 | (22) |
|
|
|
972 | (1) |
|
Software Life Cycle Models |
|
|
973 | (1) |
|
|
|
973 | (1) |
|
Benefits of the Waterfall Model |
|
|
974 | (1) |
|
Drawbacks of the Waterfall Model |
|
|
974 | (1) |
|
|
|
975 | (1) |
|
|
|
975 | (1) |
|
Benefits of a Spiral-like Model |
|
|
976 | (1) |
|
Drawbacks of a Spiral-like Model |
|
|
977 | (1) |
|
|
|
978 | (1) |
|
Software Engineering Methodologies |
|
|
978 | (1) |
|
|
|
979 | (1) |
|
The Rational Unified Process |
|
|
980 | (1) |
|
|
|
980 | (1) |
|
|
|
980 | (1) |
|
|
|
981 | (1) |
|
|
|
981 | (1) |
|
|
|
981 | (1) |
|
|
|
982 | (1) |
|
|
|
983 | (1) |
|
|
|
983 | (1) |
|
|
|
984 | (1) |
|
|
|
984 | (4) |
|
|
|
988 | (1) |
|
|
|
988 | (1) |
|
Building Your Own Process and Methodology |
|
|
989 | (1) |
|
|
|
989 | (1) |
|
Bring New Ideas to the Table |
|
|
989 | (1) |
|
Recognize What Works and What Doesn't Work |
|
|
989 | (1) |
|
|
|
989 | (1) |
|
|
|
990 | (2) |
|
|
|
992 | (1) |
|
|
|
992 | (1) |
|
Chapter 29 Writing Efficient C++ |
|
|
993 | (28) |
|
Overview of Performance and Efficiency |
|
|
994 | (1) |
|
Two Approaches to Efficiency |
|
|
994 | (1) |
|
|
|
994 | (1) |
|
Is C++ an Inefficient Language? |
|
|
994 | (1) |
|
Language-Level Efficiency |
|
|
995 | (1) |
|
Handle Objects Efficiently |
|
|
996 | (1) |
|
Pass-by-Value or Pass-by-Reference |
|
|
996 | (2) |
|
Return-by-Value or Return-by-Reference |
|
|
998 | (1) |
|
Catch Exceptions by Reference |
|
|
998 | (1) |
|
|
|
998 | (1) |
|
Avoid Creating Temporary Objects |
|
|
998 | (1) |
|
Return-Value Optimization |
|
|
999 | (1) |
|
|
|
1000 | (1) |
|
Use Inline Methods and Functions |
|
|
1001 | (1) |
|
|
|
1001 | (1) |
|
|
|
1002 | (1) |
|
|
|
1003 | (1) |
|
An Object Pool Implementation |
|
|
1003 | (3) |
|
|
|
1006 | (2) |
|
|
|
1008 | (1) |
|
Profiling Example with gprof |
|
|
1009 | (1) |
|
|
|
1009 | (3) |
|
Profiling the First Design Attempt |
|
|
1012 | (2) |
|
|
|
1014 | (1) |
|
Profiling the Second Design Attempt |
|
|
1015 | (1) |
|
Profiling Example with Visual C++ 2019 |
|
|
1016 | (3) |
|
|
|
1019 | (1) |
|
|
|
1019 | (2) |
|
Chapter 30 Becoming Adept At Testing |
|
|
1021 | (24) |
|
|
|
1022 | (1) |
|
Whose Responsibility Is Testing? |
|
|
1022 | (1) |
|
|
|
1022 | (1) |
|
|
|
1023 | (2) |
|
|
|
1025 | (1) |
|
Approaches to Unit Testing |
|
|
1026 | (1) |
|
|
|
1026 | (1) |
|
Define the Granularity of Your Tests |
|
|
1027 | (1) |
|
Brainstorm the Individual Tests |
|
|
1028 | (1) |
|
Create Sample Data and Results |
|
|
1029 | (1) |
|
|
|
1029 | (1) |
|
|
|
1030 | (1) |
|
|
|
1031 | (1) |
|
Introducing the Microsoft Visual C++ Testing Framework |
|
|
1031 | (2) |
|
|
|
1033 | (1) |
|
Building and Running Tests |
|
|
1034 | (1) |
|
|
|
1034 | (1) |
|
|
|
1035 | (3) |
|
|
|
1038 | (1) |
|
Basking in the Glorious Light of Unit Test Results |
|
|
1038 | (1) |
|
|
|
1039 | (1) |
|
|
|
1039 | (1) |
|
|
|
1039 | (1) |
|
|
|
1039 | (1) |
|
Methods of Integration Testing |
|
|
1040 | (1) |
|
|
|
1041 | (1) |
|
|
|
1041 | (1) |
|
Tips for Successful Testing |
|
|
1042 | (1) |
|
|
|
1043 | (1) |
|
|
|
1043 | (2) |
|
Chapter 31 Conquering Debugging |
|
|
1045 | (38) |
|
The Fundamental Law of Debugging |
|
|
1046 | (1) |
|
|
|
1046 | (1) |
|
|
|
1046 | (1) |
|
|
|
1047 | (1) |
|
|
|
1047 | (2) |
|
|
|
1049 | (1) |
|
|
|
1049 | (4) |
|
|
|
1053 | (4) |
|
|
|
1057 | (1) |
|
|
|
1058 | (1) |
|
|
|
1059 | (1) |
|
|
|
1059 | (1) |
|
Debugging Reproducible Bugs |
|
|
1060 | (1) |
|
Debugging Nonreproducible Bugs |
|
|
1060 | (1) |
|
|
|
1061 | (1) |
|
Debugging Memory Problems |
|
|
1062 | (1) |
|
Categories of Memory Errors |
|
|
1062 | (3) |
|
Tips for Debugging Memory Errors |
|
|
1065 | (1) |
|
Debugging Multithreaded Programs |
|
|
1066 | (1) |
|
Debugging Example: Article Citations |
|
|
1067 | (1) |
|
Buggy Implementation of an ArticleCitations Class |
|
|
1067 | (3) |
|
Testing the ArticleCitations Class |
|
|
1070 | (9) |
|
Lessons from the ArticleCitations Example |
|
|
1079 | (1) |
|
|
|
1079 | (1) |
|
|
|
1080 | (3) |
|
Chapter 32 Incorporating Design Techniques And Frameworks |
|
|
1083 | (22) |
|
"I Can Never Remember How to." |
|
|
1084 | (1) |
|
|
|
1084 | (2) |
|
Derive from an Existing Class |
|
|
1086 | (1) |
|
Write a Lambda Expression |
|
|
1086 | (1) |
|
Use the Copy-and-Swap Idiom |
|
|
1087 | (1) |
|
Throw and Catch Exceptions |
|
|
1088 | (1) |
|
|
|
1089 | (1) |
|
|
|
1089 | (1) |
|
|
|
1090 | (1) |
|
Constrain Template Parameters |
|
|
1090 | (1) |
|
There Must Be a Better Way |
|
|
1091 | (1) |
|
Resource Acquisition Is Initialization |
|
|
1091 | (2) |
|
|
|
1093 | (1) |
|
|
|
1094 | (1) |
|
Attempt #2: Single Polymorphism with Overloading |
|
|
1095 | (1) |
|
Attempt #3: Double Dispatch |
|
|
1096 | (2) |
|
|
|
1098 | (1) |
|
Using Multiple Inheritance |
|
|
1098 | (2) |
|
|
|
1100 | (1) |
|
Object-Oriented Frameworks |
|
|
1101 | (1) |
|
|
|
1101 | (1) |
|
The Model-View-Controller Paradigm |
|
|
1102 | (1) |
|
|
|
1103 | (1) |
|
|
|
1103 | (2) |
|
Chapter 33 Applying Design Patterns |
|
|
1105 | (32) |
|
|
|
1106 | (1) |
|
Example: A Logging Mechanism |
|
|
1106 | (1) |
|
Implementation of a Dependency-Injected Logger |
|
|
1106 | (2) |
|
Using Dependency Injection |
|
|
1108 | (1) |
|
The Abstract Factory Pattern |
|
|
1109 | (1) |
|
Example: A Car Factory Simulation |
|
|
1109 | (1) |
|
Implementation of an Abstract Factory |
|
|
1110 | (1) |
|
Using an Abstract Factory |
|
|
1111 | (1) |
|
The Factory Method Pattern |
|
|
1112 | (1) |
|
Example: A Second Car Factory Simulation |
|
|
1112 | (2) |
|
Implementation of a Factory |
|
|
1114 | (1) |
|
|
|
1115 | (2) |
|
|
|
1117 | (1) |
|
|
|
1117 | (1) |
|
|
|
1118 | (1) |
|
Example: Adapting a Logger Class |
|
|
1118 | (1) |
|
Implementation of an Adapter |
|
|
1119 | (1) |
|
|
|
1120 | (1) |
|
|
|
1120 | (1) |
|
Example: Hiding Network Connectivity Issues |
|
|
1121 | (1) |
|
Implementation of a Proxy |
|
|
1121 | (1) |
|
|
|
1122 | (1) |
|
|
|
1123 | (1) |
|
|
|
1124 | (1) |
|
Example: Exposing Events from Subjects |
|
|
1124 | (1) |
|
Implementation of an Observable |
|
|
1124 | (1) |
|
|
|
1125 | (1) |
|
|
|
1126 | (1) |
|
Example: Defining Styles in Web Pages |
|
|
1127 | (1) |
|
Implementation of a Decorator |
|
|
1127 | (1) |
|
|
|
1128 | (1) |
|
The Chain of Responsibility Pattern |
|
|
1129 | (1) |
|
|
|
1129 | (1) |
|
Implementation of a Chain of Responsibility |
|
|
1129 | (2) |
|
Using a Chain of Responsibility |
|
|
1131 | (1) |
|
|
|
1132 | (1) |
|
Example: A Logging Mechanism |
|
|
1132 | (1) |
|
Implementation of a Singleton |
|
|
1133 | (2) |
|
|
|
1135 | (1) |
|
|
|
1135 | (1) |
|
|
|
1135 | (2) |
|
Chapter 34 Developing Cross-Platform And Cross-Language Applications |
|
|
1137 | (28) |
|
Cross-Platform Development |
|
|
1138 | (1) |
|
|
|
1138 | (1) |
|
|
|
1138 | (1) |
|
|
|
1139 | (1) |
|
|
|
1140 | (1) |
|
|
|
1140 | (2) |
|
|
|
1142 | (1) |
|
Compiler Quirks and Extensions |
|
|
1142 | (1) |
|
|
|
1142 | (1) |
|
Handling Different Implementations |
|
|
1143 | (1) |
|
Platform-Specific Features |
|
|
1143 | (2) |
|
Cross-Language Development |
|
|
1145 | (1) |
|
|
|
1145 | (1) |
|
|
|
1145 | (4) |
|
|
|
1149 | (2) |
|
|
|
1151 | (1) |
|
C++/CLI to Use C# Code from C++ and C++ from C# |
|
|
1152 | (2) |
|
Calling C++ Code from Java with JNI |
|
|
1154 | (2) |
|
Calling Scripts from C++ Code |
|
|
1156 | (1) |
|
Calling C++ Code from Scripts |
|
|
1156 | (1) |
|
A Practical Example: Encrypting Passwords |
|
|
1157 | (2) |
|
Calling Assembly Code from C++ |
|
|
1159 | (1) |
|
|
|
1160 | (1) |
|
|
|
1160 | (5) |
|
|
|
|
Appendix A C++ Interviews |
|
|
1165 | (26) |
|
Appendix B Annotated Bibliography |
|
|
1191 | (12) |
|
Appendix C Standard Library Header Files |
|
|
1203 | (10) |
|
Appendix D Introduction To Uml |
|
|
1213 | (6) |
| Index |
|
1219 | |