Muutke küpsiste eelistusi

E-raamat: Professional C++

  • Formaat: EPUB+DRM
  • Ilmumisaeg: 24-Feb-2021
  • Kirjastus: Wrox Press
  • Keel: eng
  • ISBN-13: 9781119695455
  • Formaat - EPUB+DRM
  • Hind: 52,65 €*
  • * hind on lõplik, st. muud allahindlused enam ei rakendu
  • Lisa ostukorvi
  • Lisa soovinimekirja
  • See e-raamat on mõeldud ainult isiklikuks kasutamiseks. E-raamatuid ei saa tagastada.
  • Raamatukogudele
  • Formaat: EPUB+DRM
  • Ilmumisaeg: 24-Feb-2021
  • Kirjastus: Wrox Press
  • Keel: eng
  • ISBN-13: 9781119695455

DRM piirangud

  • Kopeerimine (copy/paste):

    ei ole lubatud

  • Printimine:

    ei ole lubatud

  • Kasutamine:

    Digitaalõiguste kaitse (DRM)
    Kirjastus on väljastanud selle e-raamatu krüpteeritud kujul, mis tähendab, et selle lugemiseks peate installeerima spetsiaalse tarkvara. Samuti peate looma endale  Adobe ID Rohkem infot siin. E-raamatut saab lugeda 1 kasutaja ning alla laadida kuni 6'de seadmesse (kõik autoriseeritud sama Adobe ID-ga).

    Vajalik tarkvara
    Mobiilsetes seadmetes (telefon või tahvelarvuti) lugemiseks peate installeerima selle tasuta rakenduse: PocketBook Reader (iOS / Android)

    PC või Mac seadmes lugemiseks peate installima Adobe Digital Editionsi (Seeon tasuta rakendus spetsiaalselt e-raamatute lugemiseks. Seda ei tohi segamini ajada Adober Reader'iga, mis tõenäoliselt on juba teie arvutisse installeeritud )

    Seda e-raamatut ei saa lugeda Amazon Kindle's. 

Improve your existing C++ competencies quickly and efficiently with this advanced volume 

Professional C++, 5th Edition raises the bar for advanced programming manuals. Complete with a comprehensive overview of the new capabilities of C++20, each feature of the newly updated programming language is explained in detail and with examples. Case studies that include extensive, working code round out the already impressive educational material found within. 

Without a doubt, the new 5th Edition of Professional C++ is the leading resource for dedicated and knowledgeable professionals who desire to advance their skills and improve their abilities. This book contains resources to help readers: 

  • Maximize the capabilities of C++ with effective design solutions  
  • Master little-known elements of the language and learn what to avoid  
  • Adopt new workarounds and testing/debugging best practices  
  • Utilize real-world program segments in your own applications 

Notoriously complex and unforgiving, C++ requires its practitioners to remain abreast of the latest developments and advancements. Professional C++, 5th Edition ensures that its readers will do just that. 

Introduction xlvii
PART I INTRODUCTION TO PROFESSIONAL C++
Chapter 1 A Crash Course In C++ And The Standard Library
3(84)
C++ Crash Course
4(1)
The Obligatory "Hello, World" Program
4(1)
Comments
5(1)
Importing Modules
5(1)
Preprocessor Directives
5(3)
The main() Function
8(1)
I/O Streams
8(1)
Namespaces
9(2)
Nested Namespace
11(1)
Namespace Alias
11(1)
Literals
11(1)
Variables
12(2)
Numerical Limits
14(1)
Zero Initialization
15(1)
Casting
15(1)
Floating-Point Numbers
16(1)
Operators
16(3)
Enumerated Types
19(2)
Old-Style Enumerated Types
21(1)
Structs
22(1)
Conditional Statements
23(1)
If/else Statements
23(1)
Switch Statements
24(1)
The Conditional Operator
25(1)
Logical Evaluation Operators
26(1)
Three-Way Comparisons
27(1)
Functions
28(2)
Function Return Type Deduction
30(1)
Current Function's Name
30(1)
Function Overloading
30(1)
Attributes
30(1)
[ [ Nodiscard]]
31(1)
[ [ Maybe unused]]
31(1)
[ [ Noreturn]]
32(1)
[ [ Deprecated]]
32(1)
[ [ Likely]] and [ [ unlikely]]
33(1)
C-Style Arrays
33(2)
Std::array
35(1)
Std::vector
36(1)
Std::pair
36(1)
Std::optional
37(1)
Structured Bindings
38(1)
Loops
38(1)
The while Loop
38(1)
The do/while Loop
39(1)
The for Loop
39(1)
The Range-Based for Loop
39(1)
Initializer Lists
40(1)
Strings in C++
40(1)
C++ as an Object-Oriented Language
41(1)
Defining Classes
41(3)
Using Classes
44(1)
Scope Resolution
44(1)
Uniform Initialization
45(3)
Designated Initializers
48(1)
Pointers and Dynamic Memory
49(1)
The Stack and the Free Store
49(1)
Working with Pointers
50(1)
Dynamically Allocated Arrays
51(1)
Null Pointer Constant
52(1)
The Use of const
53(1)
Const as a Qualifier for a Type
53(2)
Const Methods
55(1)
The constexpr Keyword
56(1)
The consteval Keyword
57(1)
References
58(1)
Reference Variables
58(3)
Reference Data Members
61(1)
Reference Parameters
61(3)
Reference Return Values
64(1)
Deciding Between References and Pointers
64(4)
Const cast()
68(1)
Exceptions
69(1)
Type Aliases
70(1)
Typedefs
71(1)
Type Inference
72(1)
The auto Keyword
72(3)
The decltype Keyword
75(1)
The Standard Library
75(1)
Your First Bigger C++ Program
75(1)
An Employee Records System
76(1)
The Employee Class
76(1)
Employee.cppm
76(2)
Employee.cpp
78(1)
EmployeeTest.cpp
79(1)
The Database Class
80(1)
Database.cppm
80(1)
Database.cpp
81(1)
DatabaseTest.cpp
82(1)
The User Interface
82(3)
Evaluating the Program
85(1)
Summary
85(1)
Exercises
85(2)
Chapter 2 Working With Strings And String Views
87(24)
Dynamic Strings
88(1)
C-Style Strings
88(2)
String Literals
90(1)
Raw String Literals
90(2)
The C++ std::string Class
92(1)
What Is Wrong with C-Style Strings?
92(1)
Using the string Class
92(3)
Std::string Literals
95(1)
CTAD with std::vector and Strings
96(1)
Numeric Conversions
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)
Nonstandard Strings
102(1)
String Formatting
103(1)
Format Specifiers
104(1)
Width
104(1)
[ Fill]align
105(1)
Sign
105(1)
#
105(1)
Type
106(1)
Precision
107(1)
0
107(1)
Format Specifier Errors
107(1)
Support for Custom Types
107(3)
Summary
110(1)
Exercises
110(1)
Chapter 3 Coding With Style
111(26)
The Importance of Looking Good
111(1)
Thinking Ahead
112(1)
Elements of Good Style
112(1)
Documenting Your Code
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)
Commenting Styles
117(1)
Commenting Every Line
117(1)
Prefix Comments
118(1)
Fixed-Format Comments
119(1)
Ad Hoc Comments
120(2)
Self-Documenting Code
122(1)
Decomposition
122(1)
Decomposition Through Refactoring
123(1)
Decomposition-by Design
124(1)
Decomposition in This Book
124(1)
Naming
124(1)
Choosing a Good Name
124(1)
Naming Conventions
125(1)
Counters
125(1)
Prefixes
126(1)
Hungarian Notation
126(1)
Getters and Setters
127(1)
Capitalization
127(1)
Namespaced Constants
127(1)
Using Language Features with Style
127(1)
Use Constants
128(1)
Use References Instead of Pointers
128(1)
Use Custom Exceptions
129(1)
Formatting
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)
Stylistic Challenges
132(1)
Summary
132(1)
Exercises
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)
Designing for C++
141(1)
Two Rules for Your Own C++ Designs
142(1)
Abstraction
142(1)
Benefiting from Abstraction
142(1)
Incorporating Abstraction in Your Design
143(1)
Reuse
144(1)
Writing Reusable Code
144(1)
Reusing Designs
145(1)
Reusing Existing Code
146(1)
A Note on Terminology
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)
Understand Licensing
153(1)
Understand Support and Know Where to Find Help
154(1)
Prototype
154(1)
Open-Source Libraries
155(2)
The C++ Standard Library
157(1)
Designing a Chess Program
157(1)
Requirements
158(1)
Design Steps
158(1)
Divide the Program into Subsystems
158(2)
Choose Threading Models
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)
Summary
166(1)
Exercises
166(3)
Chapter 5 Designing With Objects
169(18)
Am I Thinking Procedurally?
170(1)
The Object-Oriented Philosophy
170(1)
Classes
170(1)
Components
171(1)
Properties
171(1)
Behaviors
172(1)
Bringing It All Together
172(1)
Living in a World of Classes
173(1)
Over-Classification
173(1)
Overly General Classes
174(1)
Class Relationships
175(1)
The Has-a Relationship
175(1)
The Is-a Relationship (Inheritance)
176(1)
Inheritance Techniques
177(1)
Polymorphism
178(1)
The Fine Line Between Has-a and Is-a
178(3)
The Not-a Relationship
181(1)
Hierarchies
182(1)
Multiple Inheritance
183(1)
Mixin Classes
184(1)
Summary
185(1)
Exercises
185(2)
Chapter 6 Designing For Reuse
187(24)
The Reuse Philosophy
188(1)
How to Design Reusable Code
189(1)
Use Abstraction
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)
Design for Extensibility
196(2)
Design Usable Interfaces
198(1)
Consider the Audience
198(1)
Consider the Purpose
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)
The SOLID Principles
206(1)
Summary
207(1)
Exercises
207(4)
PART III C++ CODING THE PROFESSIONAL WAY
Chapter 7 Memory Management
211(38)
Working with Dynamic Memory
212(1)
How to Picture Memory
212(1)
Allocation and Deallocation
213(1)
Using new and delete
213(1)
What About My Good Friend malloc?
214(1)
When Memory Allocation Fails
215(1)
Arrays
215(1)
Arrays of Primitive Types
215(3)
Arrays of Objects
218(1)
Deleting Arrays
218(1)
Multidimensional Arrays
219(4)
Working with Pointers
223(1)
A Mental Model for Pointers
223(1)
Casting with Pointers
224(1)
Array-Pointer Duality
224(1)
Arrays Are Pointers!
224(2)
Not All Pointers Are Arrays!
226(1)
Low-Level Memory Operations
227(1)
Pointer Arithmetic
227(1)
Custom Memory Management
228(1)
Garbage Collection
228(1)
Object Pools
229(1)
Common Memory Pitfalls
229(1)
Underallocating Data Buffers and Out-of-Bounds Memory Access
229(2)
Memory Leaks
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)
Smart Pointers
234(1)
Unique ptr
235(1)
Creating unique ptrs
236(1)
Using unique ptrs
237(1)
Unique ptr and C-Style Arrays
238(1)
Custom Deleters
239(1)
Shared ptr
239(1)
Creating and Using shared ptrs
239(2)
The Need for Reference Counting
241(1)
Casting a shared ptr
242(1)
Aliasing
242(1)
Weak ptr
243(1)
Passing to Functions
244(1)
Returning from Functions
244(1)
Enable shared from this
244(1)
The Old and Removed auto ptr
245(1)
Summary
246(1)
Exercises
246(3)
Chapter 8 Gaining Proficiency With Classes And Objects
249(34)
Introducing the Spreadsheet Example
250(1)
Writing Classes
250(1)
Class Definitions
250(1)
Class Members
251(1)
Access Control
251(1)
Order of Declarations
252(1)
In-Class Member Initializers
253(1)
Defining Methods
253(1)
Accessing Data Members
254(1)
Calling Other Methods
254(1)
The this Pointer
255(2)
Using Objects
257(1)
Objects on the Stack
257(1)
Objects on the Free Store
257(1)
Understanding Object Life Cycles
258(1)
Object Creation
258(1)
Writing Constructors
259(1)
Using Constructors
260(1)
Providing Multiple Constructors
260(1)
Default Constructors
261(4)
Constructor Initializers
265(4)
Copy Constructors
269(2)
Initializer-List Constructors
271(2)
Delegating Constructors
273(1)
Converting Constructors and Explicit Constructors
273(2)
Summary of Compiler-Generated Constructors
275(1)
Object Destruction
276(1)
Assigning to Objects
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)
Objects as Return Values
280(1)
Copy Constructors and Object Members
281(1)
Summary
282(1)
Exercises
282(1)
Chapter 9 Mastering Classes And Objects
283(54)
Friends
284(1)
Dynamic Memory Allocation in Objects
285(1)
The Spreadsheet Class
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)
Rvalue References
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)
Rule of Zero
305(1)
More About Methods
306(1)
Static Methods
306(1)
Const Methods
307(1)
Mutable Data Members
308(1)
Method Overloading
308(1)
Overloading Based on const
309(1)
Explicitly Deleting Overloads
310(1)
Ref-Qualified Methods
310(1)
Inline Methods
311(2)
Default Arguments
313(1)
Different Kinds of Data Members
314(1)
Static Data Members
314(1)
Inline Variables
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)
Reference Data Members
317(1)
Nested Classes
318(1)
Enumerated Types Inside Classes
319(1)
Operator Overloading
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)
Summary
334(1)
Exercises
335(2)
Chapter 10 Discovering Inheritance Techniques
337(60)
Building Classes with Inheritance
338(1)
Extending Classes
338(1)
A Client's View of Inheritance
339(1)
A Derived Class's View of Inheritance
340(1)
Preventing Inheritance
341(1)
Overriding Methods
342(1)
The virtual Keyword
342(1)
Syntax for Overriding a Method
342(1)
A Client's View of Overridden Methods
343(1)
The override Keyword
344(2)
The Truth About virtual
346(4)
Preventing Overriding
350(1)
Inheritance for Reuse
350(1)
The WeatherPrediction Class
350(1)
Adding Functionality in a Derived Class
351(1)
Replacing Functionality in a Derived Class
352(1)
Respect Your Parents
353(1)
Parent Constructors
353(2)
Parent Destructors
355(1)
Referring to Parent Names
356(2)
Casting Up and Down
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)
A First Attempt
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)
Leveraging Polymorphism
364(1)
Future Considerations
365(2)
Multiple Inheritance
367(1)
Inheriting from Multiple Classes
367(1)
Naming Collisions and Ambiguous Base Classes
368(1)
Name Ambiguity
368(1)
Ambiguous Base Classes
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)
Inherited Constructors
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)
Run-Time Type Facilities
386(2)
Non-public Inheritance
388(1)
Virtual Base Classes
389(1)
Casts
390(1)
Static cast()
390(1)
Reinterpret cast()
391(1)
Std::bit cast()
392(1)
Dynamic cast()
393(1)
Summary of Casts
394(1)
Summary
394(1)
Exercises
395(2)
Chapter 11 Odds And Ends
397(24)
Modules
397(2)
Module Interface Files
399(2)
Module Implementation Files
401(1)
Splitting Interface from Implementation
402(1)
Visibility vs. Reachability
403(1)
Submodules
404(1)
Module Partitions
405(2)
Implementation Partitions
407(1)
Header Units
408(1)
Header Files
408(1)
Duplicate Definitions
409(1)
Circular Dependencies
409(1)
Querying Existence of Headers
410(1)
Feature Test Macros for Core Language Features
410(1)
The static Keyword
411(1)
Static Data Members and Methods
411(1)
Static Linkage
411(2)
The extern Keyword
413(1)
Static Variables in Functions
414(1)
Order of Initialization of Nonlocal Variables
415(1)
Order of Destruction of Nonlocal Variables
415(1)
C Utilities
415(1)
Variable-Length Argument Lists
415(1)
Accessing the Arguments
416(1)
Why You Shouldn't Use C-Style Variable-Length Argument Lists
417(1)
Preprocessor Macros
417(2)
Summary
419(1)
Exercises
419(2)
Chapter 12 Writing Generic Code With Templates
421(44)
Overview of Templates
422(1)
Class Templates
422(1)
Writing a Class Template
423(1)
Coding Without Templates
423(3)
A Template Grid Class
426(4)
Using the Grid Template
430(1)
How the Compiler Processes Templates
431(1)
Selective Instantiation
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)
Template Parameters
433(1)
Non-type Template Parameters
434(2)
Default Values for Type Parameters
436(1)
Class Template Argument Deduction
436(2)
Method Templates
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)
Alias Templates
447(1)
Function Templates
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)
Variable Templates
454(1)
Concepts
454(1)
Syntax
455(1)
Constraints Expression
455(1)
Requires Expressions
455(2)
Combining Concept Expressions
457(1)
Predefined Standard Concepts
457(1)
Type-Constrained auto
458(1)
Type Constraints and Function Templates
458(2)
Constraint Subsumption
460(1)
Type Constraints and Class Templates
461(1)
Type Constraints and Class Methods
461(1)
Type Constraints and Template Specialization
462(1)
Summary
463(1)
Exercises
463(2)
Chapter 13 Demystifying C++I/O
465(30)
Using Streams
466(1)
What Is a Stream, Anyway?
466(1)
Stream Sources and Destinations
467(1)
Output with Streams
468(1)
Output Basics
468(1)
Methods of Output Streams
469(1)
Handling Output Errors
470(1)
Output Manipulators
471(2)
Input with Streams
473(1)
Input Basics
473(2)
Handling Input Errors
475(1)
Input Methods
476(4)
Input Manipulators
480(1)
Input and Output with Objects
481(1)
Custom Manipulators
482(1)
String Streams
482(2)
File Streams
484(1)
Text Mode vs. Binary Mode
485(1)
Jumping Around with seek() and tell()
485(2)
Linking Streams Together
487(1)
Bidirectional I/O
488(2)
Filesystem Support Library
490(1)
Path
490(1)
Directory Entry
491(1)
Helper Functions
492(1)
Directory Iteration
492(1)
Summary
493(1)
Exercises
493(2)
Chapter 14 Handling Errors
495(40)
Errors and Exceptions
496(1)
What Are Exceptions, Anyway?
496(1)
Why Exceptions in C++Are a Good Thing
496(2)
Recommendation
498(1)
Exception Mechanics
498(1)
Throwing and Catching Exceptions
499(2)
Exception Types
501(1)
Catching Exception Objects as Reference-to-const
502(1)
Throwing and Catching Multiple Exceptions
503(2)
Matching and const
505(1)
Matching Any Exception
505(1)
Uncaught Exceptions
505(2)
Noexcept Specifier
507(1)
Noexcept(expression) Specifier
508(1)
Noexcept(expression) Operator
508(1)
Throw Lists
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)
Source Location
514(3)
Nested Exceptions
517(2)
Rethrowing Exceptions
519(1)
Stack Unwinding and Cleanup
520(1)
Use Smart Pointers
521(1)
Catch, Cleanup, and Rethrow
522(1)
Common Error-Handling Issues
523(1)
Memory Allocation Errors
523(1)
Non-throwing new
524(1)
Customizing Memory Allocation Failure Behavior
524(2)
Errors in Constructors
526(2)
Function-Try-Blocks for Constructors
528(3)
Errors in Destructors
531(1)
Summary
531(1)
Exercises
532(3)
Chapter 15 Overloading C++ Operators
535(38)
Overview of Operator Overloading
536(1)
Why Overload Operators?
536(1)
Limitations to Operator Overloading
536(1)
Choices in Operator Overloading
537(1)
Method or Global Function
537(1)
Choosing Argument Types
538(1)
Choosing Return Types
538(1)
Choosing Behavior
539(1)
Operators You Shouldn't Overload
539(1)
Summary of Overloadable Operators
540(4)
Rvalue References
544(1)
Precedence and Associativity
545(1)
Relational Operators
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)
Implementing operator*
558(1)
Implementing operator
558(1)
What in the World Are operator.* and operator->*?
559(1)
Writing Conversion Operators
559(1)
Operator auto
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)
Summary
572(1)
Exercises
572(1)
Chapter 16 Overview Of The C++ Standard Library
573(30)
Coding Principles
574(1)
Use of Templates
574(1)
Use of Operator Overloading
575(1)
Overview of the C++ Standard Library
575(1)
Strings
575(1)
Regular Expressions
576(1)
I/O Streams
576(1)
Smart Pointers
576(1)
Exceptions
576(1)
Numerics Library
577(2)
Time and Date Utilities
579(1)
Random Numbers
579(1)
Initializer Lists
579(1)
Pair and Tuple
579(1)
Vocabulary Types
580(1)
Function Objects
580(1)
Filesystem
580(1)
Multithreading
580(1)
Type Traits
581(1)
Standard Integer Types
581(1)
Standard Library Feature Test Macros
581(1)
<Version>
582(1)
Source Location
582(1)
Containers
582(1)
Vector
583(1)
List
584(1)
Forward list
584(1)
Deque
584(1)
Array
584(1)
Span
585(1)
Queue
585(1)
Priority Queue
585(1)
Stack
586(1)
Set and multiset
586(1)
Map and multimap
587(1)
Unordered Associative Containers/Hash Tables
587(1)
Bitset
588(1)
Summary of Standard Library Containers
588(3)
Algorithms
591(1)
Nonmodifying Sequence Algorithms
591(2)
Modifying Sequence Algorithms
593(2)
Operational Algorithms
595(1)
Swap Algorithms
595(1)
Partition Algorithms
595(1)
Sorting Algorithms
596(1)
Binary Search Algorithms
597(1)
Set Algorithms
597(1)
Heap Algorithms
598(1)
Minimum/Maximum Algorithms
598(1)
Numerical Processing Algorithms
599(1)
Permutation Algorithms
600(1)
Choosing an Algorithm
600(1)
Ranges Library
601(1)
What's Missing from the Standard Library
601(1)
Summary
601(1)
Exercises
601(2)
Chapter 17 Understanding Iterators And The Ranges Library
603(24)
Iterators
604(2)
Getting Iterators for Containers
606(2)
Iterator Traits
608(1)
Examples
609(1)
Stream Iterators
610(1)
Output Stream Iterator
610(1)
Input Stream Iterator
611(1)
Iterator Adapters
612(1)
Insert Iterators
612(2)
Reverse Iterators
614(1)
Move Iterators
615(1)
Ranges
616(1)
Range-Based Algorithms
617(1)
Projection
618(1)
Views
619(3)
Modifying Elements Through a View
622(1)
Mapping Elements
623(1)
Range Factories
623(2)
Input Streams as Views
625(1)
Summary
625(1)
Exercises
626(1)
Chapter 18 Standard Library Containers
627(72)
Containers Overview
628(1)
Requirements on Elements
628(2)
Exceptions and Error Checking
630(1)
Sequential Containers
631(1)
Vector
631(1)
Vector Overview
631(2)
Vector Details
633(13)
Move Semantics
646(1)
Vector Example: A Round-Robin Class
647(5)
The vector<bool> Specialization
652(1)
Deque
653(1)
List
653(1)
Accessing Elements
653(1)
Iterators
654(1)
Adding and Removing Elements
654(1)
List Size
654(1)
Special list Operations
654(2)
List Example: Determining Enrollment
656(1)
Forwardjist
657(3)
Array
660(1)
Span
661(2)
Container Adapters
663(1)
Queue
663(1)
Queue Operations
663(1)
Queue Example: A Network Packet Buffer
664(2)
Priority Queue
666(1)
Priority queue Operations
666(1)
Priority queue Example: An Error Correlator
667(1)
Stack
668(1)
Stack Operations
668(1)
Stack Example: Revised Error Correlator
669(1)
Ordered Associative Containers
669(1)
The pair Utility Class
669(1)
Map
670(1)
Constructing maps
670(1)
Inserting Elements
671(3)
Map Iterators
674(1)
Looking Up Elements
675(1)
Removing Elements
675(1)
Nodes
676(1)
Map Example: Bank Account
676(3)
Multimap
679(1)
Multimap Example: Buddy Lists
680(2)
Set
682(1)
Set Example: Access Control List
682(2)
Multiset
684(1)
Unordered Associative Containers or Hash Tables
684(1)
Hash Functions
684(2)
Unordered Map
686(3)
Unordered map Example: Phone Book
689(1)
Unorderedjnultimap
690(1)
Unordered set/unordered multiset
691(1)
Other Containers
691(1)
Standard C-Style Arrays
691(1)
Strings
692(1)
Streams
693(1)
Bitset
693(1)
Bitset Basics
693(1)
Bitwise Operators
694(1)
Bitset Example: Representing Cable Channels
694(3)
Summary
697(1)
Exercises
698(1)
Chapter 19 Function Pointers, Function Objects, And Lambda Expressions
699(26)
Function Pointers
700(2)
Pointers to Methods (and Data Members)
702(1)
Std::function
703(2)
Function Objects
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)
Logical Function Objects
709(1)
Bitwise Function Objects
709(1)
Adapter Function Objects
709(4)
Lambda Expressions
713(1)
Syntax
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)
Invokers
722(1)
Summary
723(1)
Exercises
723(2)
Chapter 20 Mastering Standard Library Algorithms
725(38)
Overview of Algorithms
726(1)
The find and find if Algorithms
726(3)
The accumulate Algorithm
729(1)
Move Semantics with Algorithms
730(1)
Algorithm Callbacks
730(1)
Algorithm Details
731(1)
Non-modifying Sequence Algorithms
731(1)
Search Algorithms
731(2)
Specialized Searchers
733(1)
Comparison Algorithms
733(3)
Counting Algorithms
736(1)
Modifying Sequence Algorithms
737(1)
Generate
737(1)
Transform
738(1)
Copy
739(1)
Move
740(2)
Replace
742(1)
Erase
742(1)
Remove
743(1)
Unique
744(1)
Shuffle
745(1)
Sample
745(1)
Reverse
746(1)
Shifting Elements
746(1)
Operational Algorithms
747(1)
For each
747(2)
For each n
749(1)
Partition Algorithms
749(1)
Sorting Algorithms
750(1)
Binary Search Algorithms
751(1)
Set Algorithms
752(3)
Minimum/Maximum Algorithms
755(1)
Parallel Algorithms
756(2)
Constrained Algorithms
758(1)
Numerical Processing Algorithms
758(1)
Iota
759(1)
Reduce Algorithms
759(1)
Scan Algorithms
760(1)
Summary
761(1)
Exercises
761(2)
Chapter 21 String Localization And Regular Expressions
763(30)
Localization
763(1)
Wide Characters
764(1)
Localizing String Literals
764(1)
Non-Western Character Sets
765(2)
Locales and Facets
767(1)
Using Locales
767(2)
Global Locale
769(1)
Character Classification
769(1)
Character Conversion
769(1)
Using Facets
770(1)
Conversions
771(1)
Regular Expressions
772(1)
ECMAScript Syntax
773(1)
Anchors
773(1)
Wildcards
773(1)
Alternation
773(1)
Grouping
774(1)
Repetition
774(1)
Precedence
775(1)
Character Set Matches
775(2)
Word Boundaries
777(1)
Back References
778(1)
Lookahead
778(1)
Regular Expressions and Raw String Literals
778(1)
Common Regular Expressions
779(1)
The regex Library
779(2)
Regex match()
781(1)
Regex match() Example
781(2)
Regex search()
783(1)
Regex search() Example
784(1)
Regex Iterator
784(1)
Regex iterator Example
785(1)
Regex token iterator
785(1)
Regex token iterator Examples
786(2)
Regex replace()
788(1)
Regex replace() Examples
789(1)
Summary
790(1)
Exercises
791(2)
Chapter 22 Date And Time Utilities
793(16)
Compile-Time Rational Numbers
794(2)
Duration
796(5)
Clock
801(1)
Time Point
802(2)
Date
804(3)
Time Zone
807(1)
Summary
808(1)
Exercises
808(1)
Chapter 23 Random Number Facilities
809(12)
C-Style Random Number Generation
810(1)
Random Number Engines
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)
Summary
819(1)
Exercises
819(2)
Chapter 24 Additional Library Utilities
821(12)
Vocabulary Types
821(1)
Variant
821(2)
Any
823(1)
Tuples
824(2)
Decompose Tuples
826(1)
Structured Bindings
827(1)
Tie
827(1)
Concatenation
828(1)
Comparisons
828(1)
Make from tuple
829(1)
Apply
829(1)
Summary
829(1)
Exercises
830(3)
PART IV MASTERING ADVANCED FEATURES OF C++
Chapter 25 Customizing And Extending The Standard Library
833(44)
Allocators
834(1)
Extending the Standard Library
835(1)
Why Extend the Standard Library?
835(1)
Writing a Standard Library Algorithm
836(1)
Find all()
836(1)
Writing a Standard Library Container
837(1)
A Basic Directed Graph
837(11)
Making directed graph a Standard Library Container
848(18)
Adding Support for Allocators
866(5)
Improving graph node
871(1)
Additional Standard Library-Like Functionality
872(2)
Further Improvements
874(1)
Other Container Types
874(1)
Summary
875(1)
Exercises
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)
Template Recursion
889(1)
An N-Dimensional Grid: First Attempt
889(1)
A Real N-Dimensional Grid
890(2)
Variadic Templates
892(1)
Type-Safe Variable-Length Argument Lists
893(2)
Variable Number of Mixin Classes
895(1)
Fold Expressions
896(2)
Metaprogramming
898(1)
Factorial at Compile Time
898(1)
Loop Unrolling
899(1)
Printing Tuples
900(2)
Constexpr If
902(1)
Using a Compile-Time Integer Sequence with Folding
903(1)
Type Traits
903(2)
Using Type Categories
905(2)
Using Type Relationships
907(1)
Using the conditional Type Trait
907(2)
Using enable if
909(1)
Using constexpr if to Simplify enable if Constructs
910(2)
Logical Operator Traits
912(1)
Static Assertions
912(1)
Metaprogramming Conclusion
913(1)
Summary
913(1)
Exercises
913(2)
Chapter 27 Multithreaded Programming With C++
915(56)
Introduction
916(2)
Race Conditions
918(1)
Tearing
919(1)
Deadlocks
919(1)
False-Sharing
920(1)
Threads
921(1)
Thread with Function Pointer
921(1)
Thread with Function Object
922(2)
Thread with Lambda
924(1)
Thread with Member Function
924(1)
Thread Local Storage
924(1)
Canceling Threads
925(1)
Automatically Joining Threads
925(1)
Retrieving Results from Threads
926(1)
Copying and Rethrowing Exceptions
926(3)
Atomic Operations Library
929(2)
Atomic Operations
931(1)
Atomic Smart Pointers
932(1)
Atomic References
932(1)
Using Atomic Types
933(2)
Waiting on Atomic Variables
935(1)
Mutual Exclusion
936(1)
Mutex Classes
936(1)
Spinlock
936(1)
Non-timed Mutex Classes
937(2)
Timed Mutex Classes
939(1)
Locks
939(1)
Lock Guard
939(1)
Uniquejock
940(1)
Sharedjock
941(1)
Acquiring Multiple Locks at Once
941(1)
Scopedjock
942(1)
Std::call once
942(1)
Examples Using Mutual Exclusion Objects
943(1)
Thread-Safe Writing to Streams
943(2)
Using Timed Locks
945(1)
Double-Checked Locking
946(1)
Condition Variables
947(1)
Spurious Wake-Ups
948(1)
Using Condition Variables
949(1)
Latches
950(1)
Barriers
951(1)
Semaphores
951(1)
Futures
952(1)
Std::promise and std::future
953(1)
Std::packaged task
954(1)
Std::async
955(1)
Exception Handling
956(1)
Std::shared future
956(2)
Example: Multithreaded Logger Class
958(4)
Thread Pools
962(1)
Coroutines
963(2)
Threading Design and Best Practices
965(1)
Summary
966(1)
Exercises
966(5)
PART V C++ SOFTEARE ENGINEERING
Chapter 28 Maximizing Software Engineering Methods
971(22)
The Need for Process
972(1)
Software Life Cycle Models
973(1)
The Waterfall Model
973(1)
Benefits of the Waterfall Model
974(1)
Drawbacks of the Waterfall Model
974(1)
Sashimi Model
975(1)
Spiral-like Models
975(1)
Benefits of a Spiral-like Model
976(1)
Drawbacks of a Spiral-like Model
977(1)
Agile
978(1)
Software Engineering Methodologies
978(1)
The Unified Process
979(1)
The Rational Unified Process
980(1)
RUP as a Product
980(1)
RUP as a Process
980(1)
RUP in Practice
981(1)
Scrum
981(1)
Roles
981(1)
The Process
982(1)
Benefits of Scrum
983(1)
Drawbacks of Scrum
983(1)
eXtreme Programming
984(1)
XP in Theory
984(4)
XP in Practice
988(1)
Software Triage
988(1)
Building Your Own Process and Methodology
989(1)
Be Open to New Ideas
989(1)
Bring New Ideas to the Table
989(1)
Recognize What Works and What Doesn't Work
989(1)
Don't Be a Renegade
989(1)
Source Code Control
990(2)
Summary
992(1)
Exercises
992(1)
Chapter 29 Writing Efficient C++
993(28)
Overview of Performance and Efficiency
994(1)
Two Approaches to Efficiency
994(1)
Two Kinds of Programs
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)
Use Move Semantics
998(1)
Avoid Creating Temporary Objects
998(1)
Return-Value Optimization
999(1)
Pre-allocate Memory
1000(1)
Use Inline Methods and Functions
1001(1)
Design-Level Efficiency
1001(1)
Cache Where Necessary
1002(1)
Use Object Pools
1003(1)
An Object Pool Implementation
1003(3)
Using the Object Pool
1006(2)
Profiling
1008(1)
Profiling Example with gprof
1009(1)
First Design Attempt
1009(3)
Profiling the First Design Attempt
1012(2)
Second Design Attempt
1014(1)
Profiling the Second Design Attempt
1015(1)
Profiling Example with Visual C++ 2019
1016(3)
Summary
1019(1)
Exercises
1019(2)
Chapter 30 Becoming Adept At Testing
1021(24)
Quality Control
1022(1)
Whose Responsibility Is Testing?
1022(1)
The Life Cycle of a Bug
1022(1)
Bug-Tracking Tools
1023(2)
Unit Testing *
1025(1)
Approaches to Unit Testing
1026(1)
The Unit Testing Process
1026(1)
Define the Granularity of Your Tests
1027(1)
Brainstorm the Individual Tests
1028(1)
Create Sample Data and Results
1029(1)
Write the Tests
1029(1)
Run the Tests
1030(1)
Unit Testing in Action
1031(1)
Introducing the Microsoft Visual C++ Testing Framework
1031(2)
Writing the First Test
1033(1)
Building and Running Tests
1034(1)
Negative Tests
1034(1)
Adding the Real Tests
1035(3)
Debugging Tests
1038(1)
Basking in the Glorious Light of Unit Test Results
1038(1)
Fuzz Testing
1039(1)
Higher-Level Testing
1039(1)
Integration Tests
1039(1)
Sample Integration Tests
1039(1)
Methods of Integration Testing
1040(1)
System Tests
1041(1)
Regression Tests
1041(1)
Tips for Successful Testing
1042(1)
Summary
1043(1)
Exercises
1043(2)
Chapter 31 Conquering Debugging
1045(38)
The Fundamental Law of Debugging
1046(1)
Bug Taxonomies
1046(1)
Avoiding Bugs
1046(1)
Planning for Bugs
1047(1)
Error Logging
1047(2)
Debug Traces
1049(1)
Debug Mode
1049(4)
Ring Buffers
1053(4)
Assertions
1057(1)
Crash Dumps
1058(1)
Debugging Techniques
1059(1)
Reproducing Bugs
1059(1)
Debugging Reproducible Bugs
1060(1)
Debugging Nonreproducible Bugs
1060(1)
Debugging Regressions
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)
Summary
1079(1)
Exercises
1080(3)
Chapter 32 Incorporating Design Techniques And Frameworks
1083(22)
"I Can Never Remember How to."
1084(1)
Write a Class
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)
Write to a File
1089(1)
Read from a File
1089(1)
Write a Class Template
1090(1)
Constrain Template Parameters
1090(1)
There Must Be a Better Way
1091(1)
Resource Acquisition Is Initialization
1091(2)
Double Dispatch
1093(1)
Attempt #1: Brute Force
1094(1)
Attempt #2: Single Polymorphism with Overloading
1095(1)
Attempt #3: Double Dispatch
1096(2)
Mixin Classes
1098(1)
Using Multiple Inheritance
1098(2)
Using Class Templates
1100(1)
Object-Oriented Frameworks
1101(1)
Working with Frameworks
1101(1)
The Model-View-Controller Paradigm
1102(1)
Summary
1103(1)
Exercises
1103(2)
Chapter 33 Applying Design Patterns
1105(32)
Dependency Injection
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)
Using a Factory
1115(2)
Other Types of Factories
1117(1)
Other Uses of Factories
1117(1)
The Adapter Pattern
1118(1)
Example: Adapting a Logger Class
1118(1)
Implementation of an Adapter
1119(1)
Using an Adapter
1120(1)
The Proxy Pattern
1120(1)
Example: Hiding Network Connectivity Issues
1121(1)
Implementation of a Proxy
1121(1)
Using a Proxy
1122(1)
The Iterator Pattern
1123(1)
The Observer Pattern
1124(1)
Example: Exposing Events from Subjects
1124(1)
Implementation of an Observable
1124(1)
Using an Observer
1125(1)
The Decorator Pattern
1126(1)
Example: Defining Styles in Web Pages
1127(1)
Implementation of a Decorator
1127(1)
Using a Decorator
1128(1)
The Chain of Responsibility Pattern
1129(1)
Example: Event Handling
1129(1)
Implementation of a Chain of Responsibility
1129(2)
Using a Chain of Responsibility
1131(1)
The Singleton Pattern
1132(1)
Example: A Logging Mechanism
1132(1)
Implementation of a Singleton
1133(2)
Using a Singleton
1135(1)
Summary
1135(1)
Exercises
1135(2)
Chapter 34 Developing Cross-Platform And Cross-Language Applications
1137(28)
Cross-Platform Development
1138(1)
Architecture Issues
1138(1)
Size of Integers
1138(1)
Binary Compatibility
1139(1)
Address Sizes
1140(1)
Byte Order
1140(2)
Implementation Issues
1142(1)
Compiler Quirks and Extensions
1142(1)
Library Implementations
1142(1)
Handling Different Implementations
1143(1)
Platform-Specific Features
1143(2)
Cross-Language Development
1145(1)
Mixing C and C++
1145(1)
Shifting Paradigms
1145(4)
Linking with C Code
1149(2)
Calling C++Code from C#
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)
Summary
1160(1)
Exercises
1160(5)
PART VI APPENDICES
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
Marc Gregoire is a Microsoft Visual C++ MVP, software architect and developer, and the founder of the Belgian C++ user group. Having previously completed critical 2G and 3G telecom software for Siemens and Nokia Siemens Networks, he currently works on X-ray, CT, and 3D geometric inspection software for Nikon Metrology. Marc is the author of Professional C++ 2nd, 3rd, and 4th editions, co-author of C++17 Standard Library Quick Reference, and technical editor for numerous published works. Visit us at wrox.com where you have access to free code samples.