Expert C++: Become a proficient programmer by learning coding best practices with C++17 and C++20's latest features. 2 Ed

Expert C++: Become a proficient programmer by learning coding best practices with C++17 and C++20's latest features. 2 Ed

Expert C++: Become a proficient programmer by learning coding best practices with C++17 and C++20's latest features. 2 Ed

Автор: Araks Tigranyan , John Asatryan , Marcelo Guerra Hahn , Shunguang Wu , Vardan Grigoryan
Дата выхода: 2023
Издательство: Packt Publishing Limited
Количество страниц: 605
Размер файла: 6,1 МБ
Тип файла: PDF
Добавил: codelibs
 Проверить на вирусы  Дополнительные материалы 

Preface xvii
Part 1: Under the Hood of C++ Programming
1
Building C++ Applications 3
Technical requirements 4
Building C++ applications 4
Preprocessing 6
Compiling 9
Linking 12
Low-level programming with C++ 17
Functions 17
Data and memory 23
Control flow 37
Details of OOP 40
Class relationships 50
Summary 52
2
Beyond Object-Oriented Programming 53
Technical requirements 54
An introduction to OOP and the C++ object model 54
Understanding objects 54
Low-level details of objects 54
High-level details of objects 57
C++ object model 58
State 62
Identity 63
Behavior 64
Mimicking a class 65
Working with classes 67
Classes from a compiler perspective 69
Initialization and destruction 71
Copying objects 73
Moving objects 76
An lvalue reference 77
Rvalue references 78
Notes on operator overloading 80
Encapsulation and the public interface 82
Class relationships 85
Aggregation and composition 86
Under the hood of inheritance and
polymorphism 87
Inheritance 87
Polymorphism 97
Virtual functions under the hood 99
Classical design patterns 102
The composite pattern 104
The decorator pattern 110
Design principles 115
The single responsibility principle 115
The open-closed principle 117
The Liskov substitution principle 119
The interface segregation principle 122
The dependency inversion principle 124
More UML in project design 125
The sequence diagram 125
Summary 130
Questions 130
Further reading 131
3
Understanding and Designing Templates 133
Technical requirements 134
Motivation for using templates 134
Function templates 134
Syntax 135
Instantiation 136
Deduction 137
Specialization and overloading 137
Class templates 139
Syntax 139
Instantiation 140
Specialization 143
Understanding variadic templates 147
Syntax 147
Examples 148
Exploring template parameters and
arguments 149
Template parameters 150
Non-type template parameter 150
Type template parameter 151
Template template parameter 153
Template arguments 154
Traits 158
Type trait implementation 158
Optimizing algorithms using traits 160
TMP and its applications 162
Summary 163
Questions 164
Further reading 164
4
Template Meta Programming 167
Technical requirements 167
Back to basics (compile-time
programming with templates) 168
Compile-time evaluation
using constexpr 176
Constant expression-specified
constructors (constexpr) 179
SFINAE AND enable_if<> 183
Argument substitution failure 184
Disabling templates with enable_if<> 187
Type traits 191
isFundamental 195
isArithmetic 196
isScalar 197
isConst 199
isVolatile 200
isPolymorphic 200
isAbstract 201
is_signed 202
Summary 202
Questions 203
5
Memory Management and Smart Pointers 205
Technical requirements 206
Understanding computer memory 206
Designing a memory storage device 206
Understanding computer memory from a
higher-level perspective 209
An example of memory management 220
Using smart pointers 223
Leveraging the RAII idiom 223
std::unique_ptr 226
std::shared_ptr and std::weak_ptr 228
Garbage collection 230
Using allocators 234
Types of allocators 235
Summary 242
Questions 243
Part 2: Designing Robust and Efficient
Applications
6
Digging into Data Structures and Algorithms in STL 247
Technical requirements 248
Sequential data structures 248
STL containers 253
Iterating containers 260
Concepts and iterators 264
Understanding concepts 264
Using iterators in C++20 266
Node-based data structures 267
Graphs and trees 272
Trees 272
Graphs 273
Hash tables 276
Algorithms 277
Search algorithms 277
Sorting 278
Summary 279
Further reading 279
Questions 280
7
Advanced Data Structures 281
Technical requirements 283
B-trees 283
Searching 287
Insertion 290
Deletion 295
Implementation details of
std::unordered_map 300
How std::unordered_map organizes
element storing and how elements
are inserted into or searched in
std::unordered_map 301
Hash functions and strategies that
are used to implement them 303
Digit selection 304
Folding 304
Using modulo 305
Collisions and how they are handled 306
Heaps and their applications 308
Advanced lists 318
Skip lists 319
XOR lists 324
Summary 326
Questions 327
Further reading 327
8
Functional Programming 329
Technical requirements 330
Functional programming revealed 330
Using ranges 333
First-class and higher-order functions 337
Why use functional programming? 341
Principles of functional programming 343
Pure functions 343
Folding 345
Delving more deeply into recursion 346
Head recursion 349
Tail recursion 350
Metaprogramming in functional C++ 351
Summary 354
Questions 355
Further reading 355
9
Concurrency and Multithreading 357
Technical requirements 358
Understanding concurrency and
multithreading 358
Processes 360
Threads 368
Working with threads 372
Waiting for threads 373
Using std::jthread 376
Passing arguments to the thread function 378
Managing threads and sharing data 379
Sharing data 382
Protecting shared data using a mutex 382
Avoiding deadlocks 383
Designing concurrent code 384
Introducing coroutines 386
Summary 389
Questions 389
Further reading 390
10
Designing Concurrent Data Structures 391
Technical requirements 391
Thread safety 392
Lock-based concurrent data
structures 392
A thread-safe singleton pattern 393
Synchronized counters 397
Concurrent stacks 399
Lock-free concurrent data structures 401
Using atomic types 402
Operations on atomic types 404
Lock-free stacks 406
A lock-free queue 409
A lock-free hashtable 410
A lock-free set 412
More operations on atomics 413
Summary 415
Questions 415
Further reading 415
11
Designing World-Ready Applications 417
Technical requirements 417
Design patterns 418
Singleton 418
Factory 419
Adapter 420
Composite 420
Observer 421
Command 422
Applying design patterns 422
The problem 423
Trade-offs 423
Systemwide impact 423
Users 423
Using domain-driven design 423
An example of a real-world project 424
Summary 432
Questions 432
Further reading 433
12
Incorporating Design Patterns in C++ Applications 435
Technical requirements 435
Design patterns in game development 436
The singleton pattern 436
The factory pattern 438
The flyway pattern 439
Design patterns in data-intensive
applications 441
The proxy pattern 441
The decorator pattern 444
The iterator pattern 448
Design patterns in enterprise
applications 448
SOA 449
Summary 449
Questions 450
Further reading 450
13
Networking and Security 451
Technical requirements 451
Introduction to networks, the OSI
model, and network programming
using sockets 452
The OSI model 452
Network applications under the hood 454
Programming network applications using
sockets 456
Understanding network protocols 457
Designing an echo server 460
Securing applications 463
Securing network applications 465
Summary 467
Questions 467
Further reading 468
14
Debugging and Testing 469
Technical requirements 469
Understanding the root cause
of an issue 469
RCA overview 470
Prevention is better than cure – good coding
behavior 471
The uninitialized variable problem 472
Side effects in compound expressions 473
Mixed signed and unsigned problems 473
Order of evaluation problem 473
Compile-time checking versus runtime
checking 474
Avoiding memory leaks 475
Debugging programs 476
Tools for debugging a C/C++ program 476
GDB overview 477
Examples of GDB 478
Setting breakpoints and inspection variable
values 479
Practical debugging strategies 483
Static and dynamic analysis 484
Static analysis 484
Dynamic analysis 484
Testing, TDD, and BDD 485
Unit testing 486
TDD 488
BDD 489
Summary 490
Further reading 491
15
Large-Scale Application Design 493
Technical requirements 494
The introduction of large-scale,
cross-platform project organizing 494
Large-scale, cross-platform project
organization in C++ 494
A large-scale, cross-platform project in C++ 495
Best practices and strategies for managing a
large-scale, cross-platform project in C++ 497
Horizontal and vertical scaling 498
Horizontal scaling 499
Vertical scaling 499
Scaling C++ applications 500
Horizontal scaling in C++ 500
Vertical scaling in C++ 500
Designing data-intensive applications 501
Data structure 503
Data processing 503
The main function 504
Summary 504
Questions 505
Further reading 506
Part 3: C++ in the AI World
16
Understanding and Using C++ in Machine Learning Tasks 509
Technical requirements 510
Introduction to AI 510
Computer vision 512
NLP 514
Knowledge reasoning 515
ML 516
Understanding ML 517
Designing an algorithm that learns 519
Categories of ML 521
Applications of ML 523
Neural networks 524
Clustering 526
Regression analysis 527
C++ and ML 529
Summary 530
Questions 531
Further reading 531
17
Using C++ in Data Science 533
Technical requirements 534
Introduction to data science 534
C++ example 535
Data capturing and manipulation 537
C++ example 538
Data cleansing and processing 540
C++ example 541
Applying machine learning
algorithms 542
C++ example 544
Data visualization 546
C++ example 546
Summary 548
Questions 549
Further reading 549
18
Designing and Implementing a Data Analysis Framework 551
Technical requirements 552
Using and processing statistical
data types 552
C++ example 553
Working with tabular and
rectangular data 555
C++ example 556
A complete ETL pipeline design
strategy 558
C++ example 560
Summary 563
Questions 564
Further reading 564
Index 565
Other Books You May Enjoy 578

 Are you an experienced C++ developer eager to take your skills to the next level? This updated edition of Expert C++ is tailored to propel you toward your goals.

 This book takes you on a journey of building C++ applications while exploring advanced techniques beyond object-oriented programming. Along the way, you'll get to grips with designing templates, including template metaprogramming, and delve into memory management and smart pointers. Once you have a solid grasp of these foundational concepts, you'll advance to more advanced topics such as data structures with STL containers and explore advanced data structures with C++. Additionally, the book covers essential aspects like functional programming, concurrency, and multithreading, and designing concurrent data structures. It also offers insights into designing world-ready applications, incorporating design patterns, and addressing networking and security concerns. Finally, it adds to your knowledge of debugging and testing and large-scale application design.

 With Expert C++ as your guide, you'll be empowered to push the boundaries of your C++ expertise and unlock new possibilities in software development.

What You Will Learn:

  • Go beyond the basics to explore advanced C++ programming techniques
  • Develop proficiency in advanced data structures and algorithm design with C++17 and C++20
  • Implement best practices and design patterns to build scalable C++ applications
  • Master C++ for machine learning, data science, and data analysis framework design
  • Design world-ready applications, incorporating networking and security considerations
  • Strengthen your understanding of C++ concurrency, multithreading, and optimizing performance with concurrent data structures

Who this book is for:

 This book will empower experienced C++ developers to achieve advanced proficiency, enabling them to build professional-grade applications with the latest features of C++17 and C++20. If you're an aspiring software engineer or computer science student, you'll able to master advanced C++ programming techniques through real-world applications that will prepare you for complex projects and real-world challenges.


Похожее:

Список отзывов:

Нет отзывов к книге.