Part 1 - Language Features
1. Quick Start
- Working With Maps
- Debug Printing
- Let’s Start!
2. Removed or Fixed Language Features
- Removed Elements
- Removing the register Keyword
- Removing Deprecated operator++(bool)
- Removing Deprecated Exception Specifications
- Removing Trigraphs
- Exercise 1
- Fixes
- New auto rules for direct-list-initialisation
- static_assert With no Message
- Different begin and end Types in Range-Based For Loop
- Exercise 2
- Compiler Support
- Exercise 3
- Quiz 1
3. Language Clarification
- Stricter Expression Evaluation Order
- The Changes
- Exercise 4
- Guaranteed Copy Elision
- Updated Value Categories
- Exercise 5
- Dynamic Memory Allocation for Over-Aligned Data
- Exercise 6
- Exception Specifications in the Type System
- Exercise 7
- Compiler Support
- Exercise 8
- Quiz 2
4. General Language Features
- Structured Binding Declarations
- The Syntax
- Modifiers
- Structured Binding Limitations
- Binding
- Examples
- Expressive Code With Structured Bindings
- Providing Structured Binding Interface for Custom Class
- Exercise 9
- Init Statement for if and switch
- Exercise 10
- Inline Variables
- How Can it Simplify the Code?
- Exercise 11
- constexpr Lambda Expressions
- Exercise 12
- Capturing [*this] in Lambda Expressions
- Exercise 13
- Nested Namespaces
- Exercise 14
- __has_include Preprocessor Expression
- Exercise 15
- Compiler support
- Exercise 16
- Quiz 3
5. Templates
- Template Argument Deduction for Class Templates
- Deduction Guides
- CTAD Limitations
- Exercise 17
- Fold Expressions
- More Examples
- Exercise 18
- if constexpr
- Why Compile Time If?
- Template Code Simplification
- Examples
- Line Printer
- Declaring Custom get
Functions - Exercise 19
- Declaring Non-Type Template Parameters With auto
- Exercise 20
- Other Changes
- Allow typename in a Template Template Parameters.
- Allow Constant Evaluation for all Non-Type Template Arguments
- Variable Templates for Traits
- Pack Expansions in Using Declarations
- Logical Operation Metafunctions
- std::void_t Transformation Trait
- Compiler Support
- Exercise 21
- Quiz 4
6. Standard Attributes
- Why Do We Need Attributes?
- Exercise 22
- Before C++11
- GCC Specific Attributes
- MSVC Specific Attributes
- Clang Specific Attributes
- Exercise 23
- Attributes in C++11 and C++14
- In C++11 we have the following attributes:
- [[noreturn]] :
- [[carries_dependency]] :
- C++14 added:
- [[deprecated]] and [[deprecated("reason")]] :
- Exercise 24
- C++17 Additions
- [[fallthrough]] Attribute
- [[maybe_unused]] Attribute
- [[nodiscard]] Attribute
- Attributes for Namespaces and Enumerators
- Ignore Unknown Attributes
- Using Attribute Namespaces Without Repetition
- Exercise 25
- Section Summary
- Compiler support
- Exercise 26
- Quiz 5
- Part 2 - The Standard Library Changes
7. std::optional
- Introduction
- When to Use
- 1) If you want to represent a nullable type.
- 2) Return a result of some computation (processing) that fails to produce a value and is not an error.
- 3) To perform lazy-loading of resources.
- 4) To pass optional parameters into functions.
- A Basic Example
- Exercise 27
- std::optional Creation
- in_place Construction
- Default Construction
- Non Copyable/Movable Types
- Constructors With Many Arguments
- std::make_optional()
- Exercise 28
- Returning std::optional
- Be Careful With Braces when Returning
- Exercise 29
- Accessing The Stored Value
- Exercise 30
- std::optional Operations
- Changing the Value & Object Lifetime
- Comparisons
- Exercise 31
- Performance & Memory Consideration
- Exercise 32
- Migration from boost::optional
- Special case: optional
and optional - Exercise 33
- Examples of std::optional
- User Name with an Optional Nickname and Age
- Parsing ints From the Command Line
- Other Examples
- Exercise 34
- Summary
- Exercise 35
- Compiler Support
- Quiz 6
8. std::variant
- The Basics
- When to Use
- A Functional Background
- Exercise 36
- std::variant Creation
- About std::monostate
- In Place Construction
- Ambiguity
- Complex Types
- Unwanted Type Conversions And Narrowing
- Exercise 37
- Changing the Values
- Object Lifetime
- Exercise 38
- Accessing the Stored Value
- Exercise 39
- Visitors for std::variant
- Overload
- Visiting Multiple Variants
- Exercise 40
- Other std::variant Operations
- Exercise 41
- Exception Safety Guarantees
- Performance & Memory Considerations
- Exercise 42
- Migration From boost::variant
- Exercise 43
- Examples of std::variant
- Error Handling
- Parsing a Command Line
- Parsing a Config File
- State Machines
- Polymorphism
- Exercise 44
- Wrap Up
- Exercise 45
- Compiler Support
- Quiz 7
9. std::any
- The Basics
- When to Use
- Exercise 46
- std::any Creation
- In Place Construction
- Complex Types
- Exercise 47
- Changing the Value
- Object Lifetime
- Exercise 48
- Accessing The Stored Value
- Exercise 49
- Performance & Memory Considerations
- Exercise 50
- Migration from boost::any
- Exercise 51
- Examples of std::any
- Parsing files
- Message Passing
- Properties
- Exercise 52
- Wrap Up
- Exercise 53
- Compiler Support
- Quiz 8
10. std::string_view
- Exercise 54
- The Basics
- When to Use
- Exercise 55
- The std::basic_string_view Type
- Exercise 56
- std::string_view Creation
- Exercise 57
- Other Operations
- Exercise 58
- Risks Using string_view
- Taking Care of Not Null-Terminated Strings
- References and Temporary Objects
- Problems with the Initial Example
- Reference Lifetime Extension
- Exercise 59
- Initializing string Members from string_view
- Exercise 60
- Handling Non-Null Terminated Strings
- Printing with printf()
- Conversion Functions Like atoi()/atof():
- A General Solution
- Exercise 61
- Performance & Memory Considerations
- Strings in Constant Expressions
- Exercise 62
- Migration from boost::string_ref and boost::string_view
- Examples
- Working with Different String APIs
- String Split
- Exercise 63
- Wrap Up
- Compiler support:
- Exercise 64
- Quiz 9
11. String Conversions
- Elementary String Conversions
- Exercise 65
- Converting From Characters to Numbers: from_chars
- Examples
- 1) Integral types
- 2) Floating Point
- Parsing a Command Line
- Exercise 66
- Converting Numbers into Characters: to_chars
- An Example
- Exercise 67
- The Benchmark
- Exercise 68
- Summary
- Compiler support
- Exercise 69
- Quiz 10
12. Searchers & String Matching
- Overview of String Matching Algorithms
- Exercise 70
- New Algorithms Available in C++17
- Using Searchers
- Exercise 71
- Examples
- Performance Experiments
- DNA Matching
- Exercise 72
- Summary
- Exercise 73
- Compiler support
- Quiz 11
13. Filesystem
- Filesystem Overview
- Core Parts of The Library
- Demo
- Exercise 74
- The Path Object
- Path Operations
- Comparison
- Path Composition
- Stream Operators
- Path Formats and Conversion
- Exercise 75
- The Directory Entry & Directory Iteration
- Traversing a Path with Directory Iterators
- directory_entry Methods
- Exercise 76
- Supporting Functions
- Getting & Displaying the File Time
- File Permissions
- Setting Permissions
- Note for Windows
- Exercise 77
- Error Handling & File Races
- File Races
- Examples
- Loading a File into a String
- Creating Directories
- Filtering Files Using Regex
- Optimisation & Code Cleanup
- Exercise 78
- Lesson Summary
- Compiler Support
- GCC/libstdc++
- Clang/libc++
- Visual Studio
- Compiler Support Summary
- Exercise 79
- Quiz 12
14. Parallel STL Algorithms
- Introduction
- Not Only Threads
- Overview
- Exercise 80
- Execution Policies
- Understanding Execution Policies
- Limitations and Unsafe Instructions
- Exceptions
- Exercise 81
- Algorithm Update
- New Algorithms
- For Each Algorithm
- Understanding Reduce Algorithms
- transform_reduce - Fused Algorithm
- Scan Algorithms
- Exercise 82
- Performance of Parallel Algorithms
- Exercise 83
- Examples
- Benchmark
- Processing Several Containers At the Same Time
- Separate Container of Indices
- Zip Iterators
- Erroneous Technique
- Counting Elements
- More Examples
- Exercise 84
- Lesson Summary
- Exercise 85
- Compiler Support
- Exercise 86
- Quiz 13
15. Other Changes In The Library
- std::byte
- Exercise 87
- Improvements for Maps and Sets
- Splicing
- Emplace Enhancements for Maps and Unordered Maps
- try_emplace Method
- insert_or_assign Method
- Exercise 88
- Return Type of Emplace Methods
- Exercise 89
- Sampling Algorithms
- Exercise 90
- New Mathematical Functions
- Exercise 91
- Shared Pointers and Arrays
- Non-member size(), data() and empty()
- Exercise 92
- constexpr Additions to the Standard Library
- Exercise 93
- std::scoped_lock
- Polymorphic Allocator, pmr
- Core elements of pmr:
- More Information
- Exercise 94
- Compiler support
- Quiz 14
16. Removed And Deprecated Library Features
- Removing auto_ptr
- Exercise 95
- Removed std::random_shuffle
- Exercise 96
- “Removing Old functional Stuff”
- Exercise 97
- std::iterator Is Deprecated
- Exercise 98
- Other Smaller Removed or Deprecated Items
- Deprecating shared_ptr::unique()
- Deprecating
- Removing Deprecated Iostreams Aliases
- Deprecate C library headers
- Deprecate std::result_of
- Deprecate std::memory_order_consume Temporarily
- Remove allocator support from std::function
- Exercise 99
- Compiler support
- Exercise 100
- Quiz 15
- Part 3 - More Examples and Use Cases
17. Refactoring with std::optional and std::variant
- The Use Case
- Exercise 101
- The Tuple Version
- Exercise 102
- A Separate Structure
- Exercise 103
- With std::optional
- With std::variant
- Exercise 104
- Wrap up
- Exercise 105
- Quiz 16
18. Enforcing Code Contracts With [[nodiscard]]
- Introduction
- Exercise 106
- Where Can It Be Used?
- Errors
- Factories / Handles
- When Returning Non-Trivial Types?
- Code With No Side Effects?
- Everywhere?!
- Exercise 107
- How to Ignore [[nodiscard]]
- Exercise 108
- Before C++17
- Exercise 109
- Summary
- Quiz 17
19. Replacing enable_if with if constexpr - Factory with Variable Arguments
- The Problem
- Exercise 110
- Before C++17
- Exercise 111
- With if constexpr
- Exercise 112
- Summary
- Quiz 18
20. How to Parallelise CSV Reader
- Introduction and Requirements
- Exercise 113
- The Serial Version
- The Main
- Converting Lines into Records
- The OrderRecord Class
- The conversion
- Calculations
- Design Enhancements
- Running the Code
- Exercise 114
- Using Parallel Algorithms
- Data Size & Instruction Count Matters
- Parallel Data Conversion
- Parallel Calculations
- Exercise 115
- Tests
- Mid Size Files 1k Lines 10 Files
- Large Set 10k Lines in 10 Files
- Largest Set 100k Lines in 10 Files
- Exercise 116
- Wrap up & Discussion
- Additional Modifications and Options
- Exercise 117
- Quiz 19