• Wrong document? Swap it for free
  • Written by students who passed
  • Immediately available after payment
  • Read online or as PDF
Sell
Where do you study
Your language
Document preview thumbnail
Preview 4 out of 678 pages
Exam (elaborations)

C++20: Get the Details.pdf

Document preview thumbnail
Preview 4 out of 678 pages

Master the latest C++20 features with this comprehensive guide. Learn about concepts, coroutines, modules, ranges, and other modern programming tools to elevate your C++ skills and stay current with cutting-edge development standards. Ideal for students and developers aiming to upgrade their C++ knowledge.

Content preview

,C++20
Rainer Grimm
This book is for sale at http://leanpub.com/c20

This version was published on 2023-09-13




This is a Leanpub book. Leanpub empowers authors and publishers with the Lean Publishing process.
Lean Publishing is the act of publishing an in-progress ebook using lightweight tools and many
iterations to get reader feedback, pivot until you have the right book and build traction once you do.

© 2020 - 2023 Rainer Grimm

,Contents

Reader Testimonials . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . i

Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ii
Conventions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ii
Special Fonts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ii
Special Boxes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . iii
Source Code . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . iii
Compilation of the Programs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . iii
How should you read the Book? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . v
Personal Notes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . v
Acknowledgments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . v
About Me . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . vi


About C++ . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
1. Historical Context . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
1.1 C++98 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
1.2 C++03 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
1.3 TR1 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
1.4 C++11 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
1.5 C++14 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
1.6 C++17 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3

2. Standardization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
2.1 Stage 3 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
2.2 Stage 2 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
2.3 Stage 1 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5


A Quick Overview of C++20 . . . . . . . . . . . . . . . . . . . . . . . . 7
3. C++20 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8

, CONTENTS


3.1 The Big Four . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
3.1.1 Concepts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
3.1.2 Modules . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
3.1.3 The Ranges Library . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
3.1.4 Coroutines . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
3.2 Core Language . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
3.2.1 Three-Way Comparison Operator . . . . . . . . . . . . . . . . . . . . . . . . 14
3.2.2 Designated Initialization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
3.2.3 consteval and constinit . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
3.2.4 Template Improvements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18
3.2.5 Lambda Improvements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
3.2.6 New Attributes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
3.3 The Standard Library . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20
3.3.1 std::span . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20
3.3.2 Container Improvements . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21
3.3.3 Arithmetic Utilities . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21
3.3.4 Formatting Library . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21
3.3.5 Calendar and Time Zones . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22
3.4 Concurrency . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24
3.4.1 Atomics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24
3.4.2 Semaphores . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25
3.4.3 Latches and Barriers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25
3.4.4 Cooperative Interruption . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26
3.4.5 std::jthread . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27
3.4.6 Synchronized Outputstreams . . . . . . . . . . . . . . . . . . . . . . . . . . 29


The Details . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32
4. Core Language . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33
4.1 Concepts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34
4.1.1 Two Wrong Approaches . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34
4.1.2 Advantages of Concepts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41
4.1.3 The long, long History . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42
4.1.4 Use of Concepts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42
4.1.5 Constrained and Unconstrained Placeholders . . . . . . . . . . . . . . . . . 54
4.1.6 Abbreviated Function Templates . . . . . . . . . . . . . . . . . . . . . . . . 57
4.1.7 Predefined Concepts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 61
4.1.8 Define Concepts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 69
4.1.9 Requires Expressions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 77
4.1.10 User-Defined Concepts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 81
4.2 Modules . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 94
4.2.1 A First Example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 94

Document information

Uploaded on
September 29, 2025
Number of pages
678
Written in
2025/2026
Type
Exam (elaborations)
Contains
Questions & answers
CA$22.99

Wrong document? Swap it for free Within 14 days of purchase and before downloading, you can choose a different document. You can simply spend the amount again.
Written by students who passed
Immediately available after payment
Read online or as PDF

Seller avatar
Reputation scores are based on the amount of documents a seller has sold for a fee and the reviews they have received for those documents. There are three levels: Bronze, Silver and Gold. The better the reputation, the more your can rely on the quality of the sellers work.
LectWoody
3.7
(122)
Sold
804
Followers
184
Items
1734
Last sold
2 days ago



Why students choose Stuvia

Created by fellow students, verified by reviews

Quality you can trust: written by students who passed their tests and reviewed by others who've used these notes.

Didn't get what you expected? Choose another document

No worries! You can instantly pick a different document that better fits what you're looking for.

Pay as you like, start learning right away

No subscription, no commitments. Pay the way you're used to via credit card and download your PDF document instantly.

Student with book image

“Bought, downloaded, and aced it. It really can be that simple.”

Alisha Student

Working on your references?

Create accurate citations in APA, MLA and Harvard with our free citation generator.

Working on your references?

Frequently asked questions