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
- Fixes
- New auto rules for direct-list-initialisation
- static_assert With no Message
- Different begin and end Types in Range-Based For Loop
- Compiler Support
- 3. Language Clarification
- Stricter Expression Evaluation Order
- The Changes
- Guaranteed Copy Elision
- Updated Value Categories
- Dynamic Memory Allocation for Over-Aligned Data
- Exception Specifications in the Type System
- Compiler Support
- 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
- Init Statement for if and switch
- Inline Variables
- How Can it Simplify the Code?
- constexpr Lambda Expressions
- Capturing [*this] in Lambda Expressions
- Nested Namespaces
- __has_include Preprocessor Expression
- Compiler support
- 5. Templates
- Template Argument Deduction for Class Templates
- Deduction Guides
- CTAD Limitations
- Fold Expressions
- More Examples
- if constexpr
- Why Compile Time If?
- Template Code Simplification
- Examples
- Line Printer
- Declaring Custom get
Functions - Declaring Non-Type Template Parameters With auto
- 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
- 6. Standard Attributes
- Why Do We Need Attributes?
- Before C++11
- GCC Specific Attributes
- MSVC Specific Attributes
- Clang Specific Attributes
- 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")]] :
- C++17 Additions
- [[fallthrough]] Attribute
- [[maybe_unused]] Attribute
- [[nodiscard]] Attribute
- Attributes for Namespaces and Enumerators
- Ignore Unknown Attributes
- Using Attribute Namespaces Without Repetition
- Section Summary
- Compiler support
- 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
- std::optional Creation
- in_place Construction
- Default Construction
- Non Copyable/Movable Types
- Constructors With Many Arguments
- std::make_optional()
- Returning std::optional
- Be Careful With Braces when Returning
- Accessing The Stored Value
- std::optional Operations
- Changing the Value & Object Lifetime
- Comparisons
- Performance & Memory Consideration
- Migration from boost::optional
- Special case: optional
and optional - Examples of std::optional
- User Name with an Optional Nickname and Age
- Parsing ints From the Command Line
- Other Examples
- Summary
- Compiler Support
- 8. std::variant
- The Basics
- When to Use
- A Functional Background
- std::variant Creation
- About std::monostate
- In Place Construction
- Ambiguity
- Complex Types
- Unwanted Type Conversions And Narrowing
- Changing the Values
- Object Lifetime
- Accessing the Stored Value
- Visitors for std::variant
- Overload
- Visiting Multiple Variants
- Other std::variant Operations
- Exception Safety Guarantees
- Performance & Memory Considerations
- Migration From boost::variant
- Examples of std::variant
- Error Handling
- Parsing a Command Line
- Parsing a Config File
- State Machines
- Polymorphism
- Wrap Up
- Compiler Support
- 9. std::any
- The Basics
- When to Use
- std::any Creation
- In Place Construction
- Complex Types
- Changing the Value
- Object Lifetime
- Accessing The Stored Value
- Performance & Memory Considerations
- Migration from boost::any
- Examples of std::any
- Parsing files
- Message Passing
- Properties
- Wrap Up
- Compiler Support
- 10. std::string_view
- The Basics
- When to Use
- The std::basic_string_view Type
- std::string_view Creation
- Other Operations
- Risks Using string_view
- Taking Care of Not Null-Terminated Strings
- References and Temporary Objects
- Problems with the Initial Example
- Reference Lifetime Extension
- Initializing string Members from string_view
- Handling Non-Null Terminated Strings
- Printing with printf()
- Conversion Functions Like atoi()/atof():
- A General Solution
- Performance & Memory Considerations
- Strings in Constant Expressions
- Migration from boost::string_ref and boost::string_view
- Examples
- Working with Different String APIs
- String Split
- Wrap Up
- Compiler support:
- 11. String Conversions
- Elementary String Conversions
- Converting From Characters to Numbers: from_chars
- Examples
- 1) Integral types
- 2) Floating Point
- Parsing a Command Line
- Converting Numbers into Characters: to_chars
- An Example
- The Benchmark
- Summary
- Compiler support
- 12. Searchers & String Matching
- Overview of String Matching Algorithms
- New Algorithms Available in C++17
- Using Searchers
- Examples
- Performance Experiments
- DNA Matching
- Summary
- Compiler support
- 13. Filesystem
- Filesystem Overview
- Core Parts of The Library
- Demo
- The Path Object
- Path Operations
- Comparison
- Path Composition
- Stream Operators
- Path Formats and Conversion
- The Directory Entry & Directory Iteration
- Traversing a Path with Directory Iterators
- directory_entry Methods
- Supporting Functions
- Getting & Displaying the File Time
- File Permissions
- Setting Permissions
- Note for Windows
- Error Handling & File Races
- File Races
- Examples
- Loading a File into a String
- Creating Directories
- Filtering Files Using Regex
- Optimisation & Code Cleanup
- Lesson Summary
- Compiler Support
- GCC/libstdc++
- Clang/libc++
- Visual Studio
- Compiler Support Summary
- 14. Parallel STL Algorithms
- Introduction
- Not Only Threads
- Overview
- Execution Policies
- Understanding Execution Policies
- Limitations and Unsafe Instructions
- Exceptions
- Algorithm Update
- New Algorithms
- For Each Algorithm
- Understanding Reduce Algorithms
- transform_reduce - Fused Algorithm
- Scan Algorithms
- Performance of Parallel Algorithms
- Examples
- Benchmark
- Processing Several Containers At the Same Time
- Separate Container of Indices
- Zip Iterators
- Erroneous Technique
- Counting Elements
- More Examples
- Lesson Summary
- Compiler Support
- 15. Other Changes In The Library
- std::byte
- Improvements for Maps and Sets
- Splicing
- Emplace Enhancements for Maps and Unordered Maps
- try_emplace Method
- insert_or_assign Method
- Return Type of Emplace Methods
- Sampling Algorithms
- New Mathematical Functions
- Shared Pointers and Arrays
- Non-member size(), data() and empty()
- constexpr Additions to the Standard Library
- std::scoped_lock
- Polymorphic Allocator, pmr
- Core elements of pmr:
- More Information
- Compiler support
- 16. Removed And Deprecated Library Features
- Removing auto_ptr
- Removed std::random_shuffle
- “Removing Old functional Stuff”
- std::iterator Is Deprecated
- 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
- Compiler support
- Part 3 - More Examples and Use Cases
- 17. Refactoring with std::optional and std::variant
- The Use Case
- The Tuple Version
- A Separate Structure
- With std::optional
- With std::variant
- Wrap up
- 18. Enforcing Code Contracts With [[nodiscard]]
- Introduction
- Where Can It Be Used?
- Errors
- Factories / Handles
- When Returning Non-Trivial Types?
- Code With No Side Effects?
- Everywhere?!
- How to Ignore [[nodiscard]]
- Before C++17
- Summary
- 19. Replacing enable_if with if constexpr - Factory with Variable Arguments
- The Problem
- Before C++17
- With if constexpr
- Summary
- 20. How to Parallelise CSV Reader
- Introduction and Requirements
- The Serial Version
- The Main
- Converting Lines into Records
- The OrderRecord Class
- The conversion
- Calculations
- Design Enhancements
- Running the Code
- Using Parallel Algorithms
- Data Size & Instruction Count Matters
- Parallel Data Conversion
- Parallel Calculations
- Tests
- Mid Size Files 1k Lines 10 Files
- Large Set 10k Lines in 10 Files
- Largest Set 100k Lines in 10 Files
- Wrap up & Discussion
- Additional Modifications and Options
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