Search icon CANCEL
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Advanced C++ Programming Cookbook

You're reading from   Advanced C++ Programming Cookbook Become an expert C++ programmer by mastering concepts like templates, concurrency, and type deduction

Arrow left icon
Product type Paperback
Published in Jan 2020
Publisher Packt
ISBN-13 9781838559915
Length 454 pages
Edition 1st Edition
Languages
Arrow right icon
Author (1):
Arrow left icon
Dr. Rian Quinn Dr. Rian Quinn
Author Profile Icon Dr. Rian Quinn
Dr. Rian Quinn
Arrow right icon
View More author details
Toc

Table of Contents (15) Chapters Close

Preface 1. Getting Started with Library Development 2. Using Exceptions for Error Handling FREE CHAPTER 3. Implementing Move Semantics 4. Using Templates for Generic Programming 5. Concurrency and Synchronization 6. Optimizing Your Code for Performance 7. Debugging and Testing 8. Creating and Implementing Your Own Container 9. Exploring Type Erasure 10. An In-Depth Look at Dynamic Allocation 11. Common Patterns in C++ 12. A Closer Look at Type Deduction 13. Bonus - Using C++20 Features 14. Other Books You May Enjoy

What this book covers

Chapter 1, Getting Started with Library Development, teaches you how to develop your own libraries, including an explanation of the principle of least surprise, how to namespace everything, how to write header-only libraries, and how to ensure others will continue to use your libraries.

Chapter 2, Using Exceptions for Error Handling, covers more advanced topics of C++ exception and error handling, including a detailed explanation of the noexcept specifier and operator, how RAII supports resource management in the presence of exceptions, why throwing from a destructor should be avoided, and how to write your own exceptions.

Chapter 3, Implementing Move Semantics, provides a detailed explanation of C++ move semantics, including an explanation of the Big Five, how to make your class movable, how to write move-only (and non-move) non-copy style classes, how to properly implement a move constructor, why const && makes no sense, and how to use reference qualification.

Chapter 4, Using Templates for Generic Programming, teaches you how to write template functions like an expert, including how to implement your own SFINAE, how to perform perfect forwarding, how to use constexpr-if statements, how to leverage tuples with parameter packs, how to loop over parameter packs at compile time, how to use type traits to implement different versions of the same function, how to use template<auto>, and how to leverage explicit type declarations in your own applications.

Chapter 5, Concurrency and Synchronization, teaches you how to use std::mutex (and friends), when to use atomic types, how to handle const classes with thread-safety using the mutable keyword, how to write a thread-safe class, how to write a thread-safe wrapper, as well as how to write asynchronous C++ including promises and futures.

Chapter 6, Optimizing Your Code for Performance, covers how to profile and benchmark your C++, how to disassemble your C++ to better understand how to optimize your code, how to locate and remove unneeded memory allocations, and why noexcept helps with optimizations.

Chapter 7, Debugging and Testing, walks you through how to use Catch2 to unit test C++, how to use Google's ASAN and UBSAN sanitizers to dynamically analyze your code for memory corruption and undefined behavior, as well as how to use NDEBUG.

Chapter 8, Creating and Implementing Your Own Container, teaches you how to write your own container wrapper by creating a std::vector that is always sorted.

Chapter 9, Exploring Type Erasure, teaches you everything you need to know about type erasure, including how to erase types through inheritance and using template, how to implement the type erasure pattern, and how to implement the delegate pattern.

Chapter 10, An In-Depth Look at Dynamic Allocation, teaches you advanced topics in dynamic memory allocation, including how to properly use std::unique_ptr and std::shared_ptr, how to handle circular references, how to type cast smart pointers, and how the heap works behind the scenes to provide your application with dynamic memory.

Chapter 11, Common Patterns in C++, explains how different patterns in computer science are implemented in C++, including the factory pattern, the singleton pattern, the decorator pattern, and the observer pattern, as well as how to implement static polymorphism to write your own static interfaces without the need for virtual inheritance.

Chapter 12, A Closer Look at Type Deduction, provides a deep dive into how type deduction is performed in C++17, including how auto, decltype, and template deduce their types automatically. This chapter concludes with examples of how to write your own C++17 user-defined deduction guides.

Chapter 13, Bonus: Using C++20 Features, provides a sneak peek at the new features coming with C++20, including concepts, modules, ranges, and coroutines.

lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime