C++17 in Detail
Course Info
This course includes 1 attempt.
If you’ve ever asked “what’s in C++17 and what does it mean for me and my code?” — and I hope you have — then this book is for you.
Herb Sutter, herbsutter.com
C++11 was a major update for the language. With all the modern features like lambdas, constexpr, variadic templates, threading, range-based for loops, smart pointers and many more powerful elements, it was enormous progress for the language. Even now, in 2018, lots of teams struggle to modernise their projects to leverage all the modern features. Later there was a minor update - C++14, which improved some things from the previous standard and added a few smaller elements. With C++17 we got a lot of mixed emotions.
Although C++17 is not as big as C++11, it's larger than C++14. Everyone expected modules, co-routines, concepts and other powerful features, but it wasn't possible to prepare everything on time.
Is C++17 weak?
Far from it! And this course will show you why!
I spent hundreds of hours investigating how the new things work in order to make a nice and practical course for you. The course will not only save your time but also will guide you through all the nuances of the language.
The course brings you exclusive content about C++17 and draws from the experience of many articles that have appeared on bfilipek.com (and cppstories.com). It is based on the book C++17 in Detail: Learn the Exciting Features of The New C++ Standard!
The chapters were rewritten from the ground-up and updated with the latest information. All of that equipped with lots of new examples and practical tips. Additionally, the course provides insight into the current implementation status, compiler support, performance issues and other relevant knowledge to boost your current projects.
If you have experience with C++11/14 and you want to move forward into the latest C++ standard, then this course is for you.
Here are the features you'll learn:
Part One: C++17 Language features
- Fixes and deprecation
- Language clarification
- General language features
- Templates
- Attributes
Part Two: C++17 The Standard Library
- std::optional
- std::variant
- std::any
- std::string_view
- String Conversions
- String Matching & Searchers
- Filesystem
- Parallel STL
- Other Changes
Part Three: More Examples and Use Cases
- Refactoring with std::optional
- Using if constexpr
- Using [[nodiscard]] attribute
- How to parallelise applications
Course Material
- 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 11 attempt allowed
- 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 21 attempt allowed
- 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 31 attempt allowed
- 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 41 attempt allowed
- 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 51 attempt allowed
- 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 61 attempt allowed
- 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 71 attempt allowed
- 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 81 attempt allowed
- 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 91 attempt allowed
- 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 101 attempt allowed
- 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 111 attempt allowed
- 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 121 attempt allowed
- 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 131 attempt allowed
- 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 141 attempt allowed
- 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 151 attempt allowed
- 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 161 attempt allowed
- 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 171 attempt allowed
- 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 181 attempt allowed
- 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 191 attempt allowed
Instructors
Bartłomiej (Bartek) Filipek is a C++ software developer from the beautiful city of Cracow in Poland He started his professional coding career in 2007. In 2010 he graduated from Jagiellonian University in Cracow, Poland, with a Master's Degree in Computer Science.
Bartek currently works at Xara, where he develops features for advanced document editors. He also has experience with desktop graphics applications, game development, large-scale systems for aviation, writing graphics drivers and even biofeedback. In the past, Bartek has also taught programming (mostly game and graphics programming courses) at local universities in Cracow.
Since 2011 Bartek has been regularly blogging at bfilipek.com and cppstories.com. Initially, the topics revolved around graphics programming, but now the blog focuses on core C++. He's also a co-organiser of the C++ User Group in Cracow. You can hear Bartek in one @CppCast episode where he talks about C++17, blogging and text processing.
Since October 2018, Bartek has been a C++ Expert for the Polish National Body, which works directly with ISO/IEC JTC 1/SC 22 (C++ Standardisation Committee).
In the same month, Bartek was awarded his first MVP title for the years 2019/2020 by Microsoft.
In his spare time, he loves assembling Lego models with his little son.
See his blog at cppstories.com.
The Leanpub 60 Day 100% Happiness Guarantee
Within 60 days of purchase you can get a 100% refund on any Leanpub purchase, in two clicks.
Now, this is technically risky for us, since you'll have the book or course files either way. But we're so confident in our products and services, and in our authors and readers, that we're happy to offer a full money back guarantee for everything we sell.
You can only find out how good something is by trying it, and because of our 100% money back guarantee there's literally no risk to do so!
So, there's no reason not to click the Add to Cart button, is there?
See full terms...
Earn $8 on a $10 Purchase, and $16 on a $20 Purchase
We pay 80% royalties on purchases of $7.99 or more, and 80% royalties minus a 50 cent flat fee on purchases between $0.99 and $7.98. You earn $8 on a $10 sale, and $16 on a $20 sale. So, if we sell 5000 non-refunded copies of your book for $20, you'll earn $80,000.
(Yes, some authors have already earned much more than that on Leanpub.)
In fact, authors have earnedover $14 millionwriting, publishing and selling on Leanpub.
Learn more about writing on Leanpub
Free Updates. DRM Free.
If you buy a Leanpub book, you get free updates for as long as the author updates the book! Many authors use Leanpub to publish their books in-progress, while they are writing them. All readers get free updates, regardless of when they bought the book or how much they paid (including free).
Most Leanpub books are available in PDF (for computers) and EPUB (for phones, tablets and Kindle). The formats that a book includes are shown at the top right corner of this page.
Finally, Leanpub books don't have any DRM copy-protection nonsense, so you can easily read them on any supported device.
Learn more about Leanpub's ebook formats and where to read them