Advanced C++ programming cookbook : become an expert C++ programmer by mastering concepts like templates, concurrency, and type deduction
This book is for C++ developers with a good understanding of the language and an interest in advanced language features, who want to obtain expert skills to solve recurring problems with tailormade solutions.
Gespeichert in:
| 1. Verfasser: | |
|---|---|
| Format: | E-Book Buch |
| Sprache: | Englisch |
| Veröffentlicht: |
Birmingham
Packt Publishing
01.01.2020
Packt Publishing, Limited |
| Ausgabe: | 1 |
| Schlagworte: | |
| ISBN: | 1838559914, 9781838559915 |
| Online-Zugang: | Volltext |
| Tags: |
Tag hinzufügen
Keine Tags, Fügen Sie den ersten Tag hinzu!
|
Inhaltsangabe:
- How it works... -- Move-only types -- Getting ready -- How to do it... -- How it works... -- Implementing the noexcept move constructor -- Getting ready -- How to do it... -- How it works... -- Learning to be wary of const& -- & -- -- Getting ready -- How to do it... -- How it works... -- Referencing qualified member functions -- Getting ready -- How to do it... -- How it works... -- Exploring objects that cannot be moved or copied -- Getting ready -- How to do it... -- How it works... -- Chapter 4: Using Templates for Generic Programming -- Technical requirements -- Implementing SFINAE -- Getting ready -- How to do it... -- How it works... -- Learning perfect forwarding -- Getting ready -- How to do it... -- How it works... -- Using if constexpr -- Getting ready -- How to do it... -- How it works... -- Using tuples to work with parameter packs -- Getting ready -- How to do it... -- How it works... -- Using type traits to overload functions and objects -- Getting ready -- How to do it... -- How it works... -- Learning how to implement template< -- auto> -- -- Getting ready -- How to do it... -- How it works... -- Working with explicit template declarations -- Getting ready -- How to do it... -- How it works... -- Chapter 5: Concurrency and Synchronization -- Technical requirements -- Working with mutexes -- Getting ready -- How to do it... -- How it works... -- std::mutex -- std::lock_guard -- std::recursive_mutex -- std::shared_mutex -- std::timed_mutex -- Using atomic data types -- Getting ready -- How to do it... -- How it works... -- Understanding what const & -- mutable mean in the context of multiple threads -- Getting ready -- How to do it... -- How it works... -- Making a class thread-safe -- Getting ready -- How to do it... -- How it works... -- Synchronization wrappers and how to implement them -- Getting ready
- How to do it... -- How it works... -- Improving performance with static polymorphism -- Getting ready -- How to do it... -- How it works... -- Chapter 12: A Closer Look at Type Deduction -- Technical requirements -- Using auto and type deduction -- Getting ready -- How to do it... -- How it works... -- Learning how decltype type deduction rules work -- Getting ready -- How to do it... -- How it works... -- Working with template function type deduction -- Getting ready -- How to do it... -- How it works... -- Leveraging template class type deduction in C++17 -- Getting ready -- How to do it... -- How it works... -- Working with user-defined type deduction in C++17 -- Getting ready -- How to do it... -- How it works... -- Chapter 13: Bonus - Using C++20 Features -- Technical requirements -- Looking at Concepts in C++20 -- Getting ready -- How to do it... -- How it works... -- Working with Modules in C++20 -- Getting ready -- How to do it... -- How it works... -- Introducing std::span, a new view on arrays -- Getting ready -- How to do it... -- How it works... -- Working with Ranges in C++20 -- Getting ready -- How to do it... -- How it works... -- Learning how to use Coroutines in C++20 -- Getting ready -- How to do it... -- How it works... -- Other Books You May Enjoy -- Index
- How it works... -- Working with iterators -- Getting ready -- How to do it... -- How it works... -- Adding the relevant parts of the std::vector API -- Getting ready -- How to do it... -- How it works... -- Chapter 9: Exploring Type Erasure -- Technical requirements -- How to erase a type with inheritance -- Getting ready -- How to do it... -- How it works... -- Using C++ templates to write generic functions -- Getting ready -- How to do it... -- How it works... -- There's more... -- See also -- Learning the C++ type eraser pattern -- Getting ready -- How to do it... -- How it works... -- Implementing delegates with type erasing -- Getting ready -- How to do it... -- How it works... -- Adding a function signature to our delegate -- Adding const support to our delegate -- Adding support for one-to-many to our delegate -- Adding support for non-member functions to our delegate -- Chapter 10: An In-Depth Look at Dynamic Allocation -- Technical requirements -- Comparing std::shared_ptr and std::unique_ptr -- Getting ready -- How to do it... -- How it works... -- Converting from a std::unique_ptr into a std::shared_ptr -- Getting ready -- How to do it... -- How it works... -- Working with circular references -- Getting ready -- How to do it... -- How it works... -- Typecasting with smart pointers -- Getting ready -- How to do it... -- How it works... -- The heap under a microscope -- Getting ready -- How to do it... -- How it works... -- Chapter 11: Common Patterns in C++ -- Technical requirements -- Learning the factory pattern -- Getting ready -- How to do it... -- How it works... -- Using the singleton pattern properly -- Getting ready -- How to do it... -- How it works... -- Extending your objects with the decorator pattern -- Getting ready -- How to do it... -- How it works... -- Adding communication with the observer pattern -- Getting ready
- Cover -- Title Page -- Copyright and Credits -- Dedication -- About Packt -- Contributors -- Table of Contents -- Preface -- Chapter 1: Getting Started with Library Development -- Technical requirements -- Understanding the principle of least surprise -- Getting ready -- How to do it... -- How it works... -- Example 1 -- Example 2 -- Example 3 -- Example 4 -- Example 5 -- Example 6 -- Example 7 -- Example 8 -- Example 9 -- How to namespace everything -- Getting ready -- How to do it... -- How it works... -- Example 1 -- Example 2 -- Header-only libraries -- Getting ready -- How to do it... -- How it works... -- How to handle includes -- Global variables -- Issues with C-style macros -- How to implement a large library as header-only -- Learning library development best practices -- Getting ready -- How to do it... -- How it works... -- What about warnings? -- Static and dynamic analysis -- Documentation -- CII Best Practices -- Learning how to use the boost APIs -- Getting ready -- How to do it... -- How it works... -- Example 1 -- Example 2 -- See also -- Chapter 2: Using Exceptions for Error Handling -- Technical requirements -- Using the noexcept specifier -- Getting ready -- How to do it... -- How it works... -- Using the noexcept operator -- Getting ready -- How to do it... -- How it works... -- Using RAII -- Getting ready -- How to do it... -- How it works... -- Learning why to never throw exceptions in destructors -- Getting ready -- How to do it... -- How it works... -- Easily creating your own exception classes -- Getting ready -- How to do it... -- How it works... -- Chapter 3: Implementing Move Semantics -- Technical requirements -- Using compiler-generated special class member functions and the Big Five -- Getting ready -- How to do it... -- How it works... -- Making your class movable -- Getting ready -- How to do it...
- How to do it... -- How it works... -- Blocking operations versus asynchronous programming -- Getting ready -- How to do it... -- How it works... -- Working with promises and futures -- Getting ready -- How to do it... -- How it works... -- Chapter 6: Optimizing Your Code for Performance -- Technical requirements -- Benchmarking your code -- Getting ready -- How to do it... -- How it works... -- Looking at assembly code -- Getting ready -- How to do it... -- How it works... -- Reducing the number of memory allocations -- Getting ready -- How to do it... -- How it works... -- Declaring noexcept -- Getting ready -- How to do it... -- How it works... -- Chapter 7: Debugging and Testing -- Technical requirements -- Getting to grips with unit testing -- Getting ready -- How to do it... -- How it works... -- Working with ASAN, the address sanitizer -- Getting ready -- How to do it... -- How it works... -- Memory leak error -- Memory deleted twice -- Accessing invalid memory -- Using memory after deleting it -- Deleting memory that was never allocated -- Working with UBSAN, the undefined behavior sanitizer -- Getting ready -- How to do it... -- How it works... -- Divide-by-zero errors -- Null-pointer dereferences -- Out-of-bounds errors -- Overflow errors -- Using #ifndef NDEBUG to conditionally execute additional checks -- Getting ready -- How to do it... -- How it works... -- Chapter 8: Creating and Implementing Your Own Container -- Technical requirements -- Using a simple wrapper around std::vector -- Getting ready -- How to do it... -- How it works... -- Default constructor -- Custom allocator constructor -- Count constructors -- Copy/move constructors -- Initializer list constructor -- Usage -- Adding elements to our container -- Usage of push/emplace -- Adding the relevant parts of the std::set API -- Getting ready -- How to do it...

