C++ 20 (2a) New Features

Video description

C++ is popular for its incredible performance and suitability for operating systems, games, embedded software, and more. This course gets you up-to-date with the very latest components in C++20/C++2a so you can harness its new enhancements and get ahead of the game by leveraging its features!

We cover what C++20/C++2a is and the current standardization status. We also discover some new syntactic sugars that enable you to write shorter but more powerful code. You'll learn about the new and improved ranges and iterators, explore key examples of filter stacking, and learn how ranges simplify iterator-heavy code. Crucially, you'll master how to migrate to C++20/C++2a in the easiest possible way, and why you should!

C++20/C++2a brings new features to the synchronization library, including atomic smart pointers, latchers, and barriers. We review its all-new coroutines (a major concept found in other leading programming languages that simplifies writing code for parallel execution).

By the end of the course, you'll use up-to-date insights into the full features of C++20/C++2a to facilitate efficient and fast coding within your own projects.

What You Will Learn

  • Migrate a project on older versions of C++ to C++20/C++2a
  • Code more efficiently with string and numbers
  • New and better ways to work with string formatting using the new std::format in C++20/C++2a
  • Implement the new comparison operator on the core language and use a custom example in user-defined types
  • Discover newly improved synchronization and thread coordination, including support for efficient atomic waiting, lock-free integral types, and more
  • Use concepts to perform compile-time validation of template arguments and perform function dispatches based on type properties

Audience

This course is ideal for developers who are already proficient in C++ (previous versions) and want to get up-to-date with the latest C++20/C++2a version and its features and benefits.

About The Author

Daniel Zawadzki: Daniel Zawadzki is a software developer with 15 years' experience. His career has mostly focused on embedded development for various devices such as phones, set-top boxes, and mobile telephony base stations, though he did make a slight detour into investment banking along the way. His language of choice (he has over 5 years' experience with it) is C++ because of its efficiency and predictable resource usage. Currently, his interests revolve around the architecture of distributed systems. He lives in Wrocaw, Poland.

Table of contents

  1. Chapter 1 : Getting Started with C++20
    1. The Course Overview
    2. Standardization Process of C++20
    3. Migrating to C++20
    4. How to Build Examples
  2. Chapter 2 : String Formatting Using New std::format
    1. Rationale for std::format
    2. std::format: Placeholders and Syntax
    3. std::format_to and std::format_to_n
    4. Formatting User Defined Types
    5. Migrating Stdio and Iostreams to std::format
  3. Chapter 3 : Ranges - Iterators Reinvented
    1. Rationale for Ranges
    2. What's New in Ranges
    3. Using Ranges
    4. Composing Ranges
  4. Chapter 4 : New Comparison Operator =>
    1. Rationale Behind New Comparison Operator
    2. Usage of => Operator and How to Make Comparisons
    3. Rewriting and Synthetizing Expressions
    4. Associated Changes in Operator==
    5. Returning Value of the Spaceship Operator
  5. Chapter 5 : Modules
    1. Rationale Behind the Modules
    2. How to Define a Module
    3. Partitioning of Modules
    4. Compiling and Linking Modules into an Executable
  6. Chapter 6 : Implementing Concepts
    1. Rationale Behind Concepts
    2. Concepts as Compile Time Predicates
    3. Defining Own Concepts
    4. Concepts Library
  7. Chapter 7 : New Synchronization Library Extensions
    1. Atomic Smart Pointers
    2. Efficient Atomic Waiting
    3. Lightweight Access Coordination
    4. Latches and Barriers
  8. Chapter 8 : Coroutines
    1. The Rationale Behind Coroutines
    2. Concept of Splitting Execution State and the Thread of Execution
    3. Coroutine Anatomy
    4. Generator Expressions
    5. Example of Use
  9. Chapter 9 : Other Features and Improvements
    1. Using Enum
    2. Improvements to Lambda Expressions
    3. Designated Initializers
    4. constexpr Extensions
    5. Course Summary

Product information

  • Title: C++ 20 (2a) New Features
  • Author(s): Daniel Zawadzki
  • Release date: February 2020
  • Publisher(s): Packt Publishing
  • ISBN: 9781839216909