SlideShare a Scribd company logo
1 of 20
Download to read offline
Overview of C++20 and a
deeper look into modules
export module cpp20;
export bool doModulesRock()
{
return true;
}
Overview of C++20 and a deeper look into modules
Speaker
● Marius Meisenzahl
● Co-founder of
○ located in Bochum
○ we build software from embedded to web
○ we offer training for
■ testing
■ software architecture
■ DevOps
■ ...
2
/meisenzahl /meisenzahl
Overview of C++20 and a deeper look into modules
C++20
Core Language Library Concurrency
Four
The Big Five
● Three-way comparison
operator
● Strings literals as template
parameters
● constexpr virtual functions
● Redefinition of volatile
● Designated initializers
● Various lambda improvements
● New standard attributes
● consteval and constinit
keyword
● std=:source_location
● Calendar and
time-zone
● std=:span as a
view on a
contiguous array
● constexpr
containers such
as std=:string
and
std=:vector
● std=:format
● std=:atomic_ref<T>
● std=:atomic<std=:shared_ptr<T=>
and
std=:atomic<std=:weak_ptr<T=>
● Floating point atomics
● Waiting on atomics
● Semaphores, latches and barriers
● std=:jthread
● Concepts
● Contracts
● Coroutines
● Ranges
● Modules
3
Overview of C++20 and a deeper look into modules
Core Language > std=:source_location
● Provides access to file name, line number, ...
● Modern alternative to preprocessor macros like =_FILE=_ and =_LINE=_
● Prime candidate for custom logging functionality in combination with
std=:format
https://en.cppreference.com/w/cpp/utility/source_location
4
Overview of C++20 and a deeper look into modules
Library > std=:format
● https://github.com/fmtlib/fmt is integrated into C++
● Python like string formatting
● Define formatting rules for custom types
fmt=:print("Hello, {}!", "world");
std=:string s = fmt=:format("I'd rather be {1} than {0}.", "right", "happy");
5
Overview of C++20 and a deeper look into modules
Concurrency > std=:jthread
● A new kind of std=:thread
● Can automatically join
● Can be interrupted
○ std=:interrupt_token
https://www.modernescpp.com/index.php/a-new-thread-with-c-20-std-jthread
6
Overview of C++20 and a deeper look into modules
Contracts
int push(queue& q, int val)
[[ expects: !q.full() ]]
[[ ensures !q.empty() ]]
{
==.
[[assert: q.is_ok() ]]
==.
}
https://www.reddit.com/r/cpp/comments/cmk7ek/what_happened_to_c20_contracts/
7
Precondition
Postcondition
Assertion
Overview of C++20 and a deeper look into modules
Concepts
● Extension of templates
○ specify which semantic categories are allowed
● Templates can be used more expressive
● Check types during compile time
○ “is sortable”, “is equality comparable”, …
https://www.modernescpp.com/index.php/c-20-concepts-the-details
8
Overview of C++20 and a deeper look into modules
Coroutines
● Asynchronous programming
○ cooperative multitasking, event loops, ...
○ new keywords co_await and co_yield
==.
size_t n = co_await socket.async_read_some(buffer(data));
co_await async_write(socket, buffer(data, n));
==.
https://en.cppreference.com/w/cpp/language/coroutines
9
Overview of C++20 and a deeper look into modules
Ranges
● Apply algorithms of STL on containers
○ connect them with pipe operator
● Use infinite data streams
auto children_names =
all_people
| filter([](const auto& person) { return person.age < 14; })
| transform([](const auto& person) { return person.name; })
| to_vector;
https://vector-of-bool.github.io/2019/10/21/rngs-static-ovr.html
10
Overview of C++20 and a deeper look into modules
Modules
● Alternative to header and implementation files
○ can halve the number of files in the code base
● No more include guards and/or #pragma once
○ But you can also separate between interface and implementation
● Faster compilation times?!
○ “Reduce build times due to not reparsing large header files”
■ https://gcc.gnu.org/wiki/cxx-modules
○ http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2019/p1441r1.pdf
● Isolation of preprocessor macros
● Better way to express which parts of a library are exported
https://vector-of-bool.github.io/2019/03/10/modules-1.html
11
Overview of C++20 and a deeper look into modules
Modules > Names
module-name:
[module-name-qualifier] identifier ;
module-name-qualifier:
identifier "." | module-name-qualifier identifier "." ;
=> speech | speech.english
12
Overview of C++20 and a deeper look into modules
Modules > Declaration
module-declaration:
["export"] "module" module-name [module-partition] [attribute-specifier-seq] ";" ;
module-partition:
":" module-name ;
=> export module example;
13
Overview of C++20 and a deeper look into modules
Modules > Partitions and “Submodules”
Partitions
export module speech;
export import :english;
export import :spanish;
“Submodules” → Separate modules
export module speech;
export import speech.english;
export import speech.spanish;
14
Overview of C++20 and a deeper look into modules
Modules > Interfaces
hello.cppm
export module hello;
export const char *greet() { return "Hello, world!"; }
15
Overview of C++20 and a deeper look into modules
Modules > Interfaces and Implementations
hello.cppm
export module hello;
export const char *greet();
hello.cpp
module hello;
const char *greet()
{ return "Hello, world!"; }
16
Overview of C++20 and a deeper look into modules
Modules > What can be exported?
● namespace
● class
● struct
● non-static variables/constants
● ...
Understanding C++ Modules: Part 2: export, import, visible, and reachable
17
Overview of C++20 and a deeper look into modules
Modules > Interoperability
Every compiler uses it’s own binary format. You
can not interchange the precompiled modules.
https://www.reddit.com/r/cpp/comments/d5dxr3/do_c20_modules_have_a_st
andard_binary_format_if/
18
Overview of C++20 and a deeper look into modules
Compiler support
TL;DR: WIP
https://en.cppreference.com/w/cpp/compiler_support
https://clang.llvm.org/cxx_status.html
https://gcc.gnu.org/projects/cxx-status.html
https://docs.microsoft.com/en-us/cpp/overview/visual-cpp-language-conform
ance?view=vs-2019
19
Overview of C++20 and a deeper look into modules
Resources
● https://isocpp.org/
● http://www.open-std.org/jtc1/sc22/wg21/docs/papers/
● https://en.wikipedia.org/wiki/C%2B%2B20
● https://www.reddit.com/r/cpp/comments/cfk9de/201907_cologne_iso_c_committee_trip_report_the/
● https://docs.microsoft.com/en-us/cpp/cpp/cpp-language-reference
● https://en.cppreference.com/w/
● https://vector-of-bool.github.io/
● https://blog.panicsoftware.com/
● http://modernescpp.com/
20

More Related Content

What's hot

Operator overloading2
Operator overloading2Operator overloading2
Operator overloading2zindadili
 
Objective-C Runtime overview
Objective-C Runtime overviewObjective-C Runtime overview
Objective-C Runtime overviewFantageek
 
Labsheet 6 - FP 201
Labsheet 6 - FP 201Labsheet 6 - FP 201
Labsheet 6 - FP 201rohassanie
 
C Programming Training In Ambala ! BATRA COMPUTER CENTRE
C Programming Training In Ambala ! BATRA COMPUTER CENTREC Programming Training In Ambala ! BATRA COMPUTER CENTRE
C Programming Training In Ambala ! BATRA COMPUTER CENTREjatin batra
 

What's hot (8)

C# p3
C# p3C# p3
C# p3
 
Roslyn: el futuro de C#
Roslyn: el futuro de C#Roslyn: el futuro de C#
Roslyn: el futuro de C#
 
Operator overloading2
Operator overloading2Operator overloading2
Operator overloading2
 
Objective-C Runtime overview
Objective-C Runtime overviewObjective-C Runtime overview
Objective-C Runtime overview
 
Labsheet 6 - FP 201
Labsheet 6 - FP 201Labsheet 6 - FP 201
Labsheet 6 - FP 201
 
C Programming Training In Ambala ! BATRA COMPUTER CENTRE
C Programming Training In Ambala ! BATRA COMPUTER CENTREC Programming Training In Ambala ! BATRA COMPUTER CENTRE
C Programming Training In Ambala ! BATRA COMPUTER CENTRE
 
29. Treffen - Tobias Meier - TypeScript
29. Treffen - Tobias Meier - TypeScript29. Treffen - Tobias Meier - TypeScript
29. Treffen - Tobias Meier - TypeScript
 
Codejunk Ignitesd
Codejunk IgnitesdCodejunk Ignitesd
Codejunk Ignitesd
 

Similar to Overview of C++20 and a deeper look into modules

Introduction-to-C-Part-1.pdf
Introduction-to-C-Part-1.pdfIntroduction-to-C-Part-1.pdf
Introduction-to-C-Part-1.pdfAnassElHousni
 
Антон Бикинеев, Writing good std::future&lt; C++ >
Антон Бикинеев, Writing good std::future&lt; C++ >Антон Бикинеев, Writing good std::future&lt; C++ >
Антон Бикинеев, Writing good std::future&lt; C++ >Sergey Platonov
 
Introduction-to-C-Part-1.pptx
Introduction-to-C-Part-1.pptxIntroduction-to-C-Part-1.pptx
Introduction-to-C-Part-1.pptxNEHARAJPUT239591
 
Introduction-to-C-Part-1 JSAHSHAHSJAHSJAHSJHASJ
Introduction-to-C-Part-1 JSAHSHAHSJAHSJAHSJHASJIntroduction-to-C-Part-1 JSAHSHAHSJAHSJAHSJHASJ
Introduction-to-C-Part-1 JSAHSHAHSJAHSJAHSJHASJmeharikiros2
 
Writing good std::future&lt;c++>
Writing good std::future&lt;c++>Writing good std::future&lt;c++>
Writing good std::future&lt;c++>corehard_by
 
Writing good std::future&lt;c++>
Writing good std::future&lt;c++>Writing good std::future&lt;c++>
Writing good std::future&lt;c++>Anton Bikineev
 
SC20 SYCL and C++ Birds of a Feather 19th Nov 2020
SC20 SYCL and C++ Birds of a Feather 19th Nov 2020SC20 SYCL and C++ Birds of a Feather 19th Nov 2020
SC20 SYCL and C++ Birds of a Feather 19th Nov 2020rodburns
 
Introduction-to-C-Part-1 (1).doc
Introduction-to-C-Part-1 (1).docIntroduction-to-C-Part-1 (1).doc
Introduction-to-C-Part-1 (1).docMayurWagh46
 
C++ helps you to format the I/O operations like determining the number of dig...
C++ helps you to format the I/O operations like determining the number of dig...C++ helps you to format the I/O operations like determining the number of dig...
C++ helps you to format the I/O operations like determining the number of dig...bhargavi804095
 
С++ without new and delete
С++ without new and deleteС++ without new and delete
С++ without new and deletePlatonov Sergey
 
С++ without new and delete
С++ without new and deleteС++ without new and delete
С++ without new and deletePlatonov Sergey
 
C++ was developed by Bjarne Stroustrup, as an extension to the C language. cp...
C++ was developed by Bjarne Stroustrup, as an extension to the C language. cp...C++ was developed by Bjarne Stroustrup, as an extension to the C language. cp...
C++ was developed by Bjarne Stroustrup, as an extension to the C language. cp...bhargavi804095
 
How to create an Angular builder
How to create an Angular builderHow to create an Angular builder
How to create an Angular builderMaurizio Vitale
 
Debugging and Profiling C++ Template Metaprograms
Debugging and Profiling C++ Template MetaprogramsDebugging and Profiling C++ Template Metaprograms
Debugging and Profiling C++ Template MetaprogramsPlatonov Sergey
 

Similar to Overview of C++20 and a deeper look into modules (20)

Introduction-to-C-Part-1.pdf
Introduction-to-C-Part-1.pdfIntroduction-to-C-Part-1.pdf
Introduction-to-C-Part-1.pdf
 
Антон Бикинеев, Writing good std::future&lt; C++ >
Антон Бикинеев, Writing good std::future&lt; C++ >Антон Бикинеев, Writing good std::future&lt; C++ >
Антон Бикинеев, Writing good std::future&lt; C++ >
 
Beyond C++17
Beyond C++17Beyond C++17
Beyond C++17
 
Introduction-to-C-Part-1.pptx
Introduction-to-C-Part-1.pptxIntroduction-to-C-Part-1.pptx
Introduction-to-C-Part-1.pptx
 
Introduction-to-C-Part-1 JSAHSHAHSJAHSJAHSJHASJ
Introduction-to-C-Part-1 JSAHSHAHSJAHSJAHSJHASJIntroduction-to-C-Part-1 JSAHSHAHSJAHSJAHSJHASJ
Introduction-to-C-Part-1 JSAHSHAHSJAHSJAHSJHASJ
 
Writing good std::future&lt;c++>
Writing good std::future&lt;c++>Writing good std::future&lt;c++>
Writing good std::future&lt;c++>
 
Writing good std::future&lt;c++>
Writing good std::future&lt;c++>Writing good std::future&lt;c++>
Writing good std::future&lt;c++>
 
11 cpp
11 cpp11 cpp
11 cpp
 
SC20 SYCL and C++ Birds of a Feather 19th Nov 2020
SC20 SYCL and C++ Birds of a Feather 19th Nov 2020SC20 SYCL and C++ Birds of a Feather 19th Nov 2020
SC20 SYCL and C++ Birds of a Feather 19th Nov 2020
 
Introduction-to-C-Part-1 (1).doc
Introduction-to-C-Part-1 (1).docIntroduction-to-C-Part-1 (1).doc
Introduction-to-C-Part-1 (1).doc
 
C++ helps you to format the I/O operations like determining the number of dig...
C++ helps you to format the I/O operations like determining the number of dig...C++ helps you to format the I/O operations like determining the number of dig...
C++ helps you to format the I/O operations like determining the number of dig...
 
C++Basics2022.pptx
C++Basics2022.pptxC++Basics2022.pptx
C++Basics2022.pptx
 
С++ without new and delete
С++ without new and deleteС++ without new and delete
С++ without new and delete
 
С++ without new and delete
С++ without new and deleteС++ without new and delete
С++ without new and delete
 
C++ was developed by Bjarne Stroustrup, as an extension to the C language. cp...
C++ was developed by Bjarne Stroustrup, as an extension to the C language. cp...C++ was developed by Bjarne Stroustrup, as an extension to the C language. cp...
C++ was developed by Bjarne Stroustrup, as an extension to the C language. cp...
 
How to create an Angular builder
How to create an Angular builderHow to create an Angular builder
How to create an Angular builder
 
Lab 1.pptx
Lab 1.pptxLab 1.pptx
Lab 1.pptx
 
Intro to c++
Intro to c++Intro to c++
Intro to c++
 
Debugging and Profiling C++ Template Metaprograms
Debugging and Profiling C++ Template MetaprogramsDebugging and Profiling C++ Template Metaprograms
Debugging and Profiling C++ Template Metaprograms
 
Return of c++
Return of c++Return of c++
Return of c++
 

Recently uploaded

Automate your Kamailio Test Calls - Kamailio World 2024
Automate your Kamailio Test Calls - Kamailio World 2024Automate your Kamailio Test Calls - Kamailio World 2024
Automate your Kamailio Test Calls - Kamailio World 2024Andreas Granig
 
Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideBuilding Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideChristina Lin
 
What are the features of Vehicle Tracking System?
What are the features of Vehicle Tracking System?What are the features of Vehicle Tracking System?
What are the features of Vehicle Tracking System?Watsoo Telematics
 
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...MyIntelliSource, Inc.
 
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...soniya singh
 
Call Girls in Naraina Delhi 💯Call Us 🔝8264348440🔝
Call Girls in Naraina Delhi 💯Call Us 🔝8264348440🔝Call Girls in Naraina Delhi 💯Call Us 🔝8264348440🔝
Call Girls in Naraina Delhi 💯Call Us 🔝8264348440🔝soniya singh
 
Implementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with AzureImplementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with AzureDinusha Kumarasiri
 
Cloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackCloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackVICTOR MAESTRE RAMIREZ
 
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...kellynguyen01
 
Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...OnePlan Solutions
 
Project Based Learning (A.I).pptx detail explanation
Project Based Learning (A.I).pptx detail explanationProject Based Learning (A.I).pptx detail explanation
Project Based Learning (A.I).pptx detail explanationkaushalgiri8080
 
Engage Usergroup 2024 - The Good The Bad_The Ugly
Engage Usergroup 2024 - The Good The Bad_The UglyEngage Usergroup 2024 - The Good The Bad_The Ugly
Engage Usergroup 2024 - The Good The Bad_The UglyFrank van der Linden
 
cybersecurity notes for mca students for learning
cybersecurity notes for mca students for learningcybersecurity notes for mca students for learning
cybersecurity notes for mca students for learningVitsRangannavar
 
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer DataAdobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer DataBradBedford3
 
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样umasea
 
buds n tech IT solutions
buds n  tech IT                solutionsbuds n  tech IT                solutions
buds n tech IT solutionsmonugehlot87
 
Unit 1.1 Excite Part 1, class 9, cbse...
Unit 1.1 Excite Part 1, class 9, cbse...Unit 1.1 Excite Part 1, class 9, cbse...
Unit 1.1 Excite Part 1, class 9, cbse...aditisharan08
 
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...MyIntelliSource, Inc.
 
Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)OPEN KNOWLEDGE GmbH
 

Recently uploaded (20)

Automate your Kamailio Test Calls - Kamailio World 2024
Automate your Kamailio Test Calls - Kamailio World 2024Automate your Kamailio Test Calls - Kamailio World 2024
Automate your Kamailio Test Calls - Kamailio World 2024
 
Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideBuilding Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
 
What are the features of Vehicle Tracking System?
What are the features of Vehicle Tracking System?What are the features of Vehicle Tracking System?
What are the features of Vehicle Tracking System?
 
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
 
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
 
Call Girls in Naraina Delhi 💯Call Us 🔝8264348440🔝
Call Girls in Naraina Delhi 💯Call Us 🔝8264348440🔝Call Girls in Naraina Delhi 💯Call Us 🔝8264348440🔝
Call Girls in Naraina Delhi 💯Call Us 🔝8264348440🔝
 
Implementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with AzureImplementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with Azure
 
Cloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackCloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStack
 
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
 
Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...
 
Project Based Learning (A.I).pptx detail explanation
Project Based Learning (A.I).pptx detail explanationProject Based Learning (A.I).pptx detail explanation
Project Based Learning (A.I).pptx detail explanation
 
Engage Usergroup 2024 - The Good The Bad_The Ugly
Engage Usergroup 2024 - The Good The Bad_The UglyEngage Usergroup 2024 - The Good The Bad_The Ugly
Engage Usergroup 2024 - The Good The Bad_The Ugly
 
cybersecurity notes for mca students for learning
cybersecurity notes for mca students for learningcybersecurity notes for mca students for learning
cybersecurity notes for mca students for learning
 
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer DataAdobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
 
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
 
Call Girls In Mukherjee Nagar 📱 9999965857 🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...
Call Girls In Mukherjee Nagar 📱  9999965857  🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...Call Girls In Mukherjee Nagar 📱  9999965857  🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...
Call Girls In Mukherjee Nagar 📱 9999965857 🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...
 
buds n tech IT solutions
buds n  tech IT                solutionsbuds n  tech IT                solutions
buds n tech IT solutions
 
Unit 1.1 Excite Part 1, class 9, cbse...
Unit 1.1 Excite Part 1, class 9, cbse...Unit 1.1 Excite Part 1, class 9, cbse...
Unit 1.1 Excite Part 1, class 9, cbse...
 
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
 
Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)
 

Overview of C++20 and a deeper look into modules

  • 1. Overview of C++20 and a deeper look into modules export module cpp20; export bool doModulesRock() { return true; }
  • 2. Overview of C++20 and a deeper look into modules Speaker ● Marius Meisenzahl ● Co-founder of ○ located in Bochum ○ we build software from embedded to web ○ we offer training for ■ testing ■ software architecture ■ DevOps ■ ... 2 /meisenzahl /meisenzahl
  • 3. Overview of C++20 and a deeper look into modules C++20 Core Language Library Concurrency Four The Big Five ● Three-way comparison operator ● Strings literals as template parameters ● constexpr virtual functions ● Redefinition of volatile ● Designated initializers ● Various lambda improvements ● New standard attributes ● consteval and constinit keyword ● std=:source_location ● Calendar and time-zone ● std=:span as a view on a contiguous array ● constexpr containers such as std=:string and std=:vector ● std=:format ● std=:atomic_ref<T> ● std=:atomic<std=:shared_ptr<T=> and std=:atomic<std=:weak_ptr<T=> ● Floating point atomics ● Waiting on atomics ● Semaphores, latches and barriers ● std=:jthread ● Concepts ● Contracts ● Coroutines ● Ranges ● Modules 3
  • 4. Overview of C++20 and a deeper look into modules Core Language > std=:source_location ● Provides access to file name, line number, ... ● Modern alternative to preprocessor macros like =_FILE=_ and =_LINE=_ ● Prime candidate for custom logging functionality in combination with std=:format https://en.cppreference.com/w/cpp/utility/source_location 4
  • 5. Overview of C++20 and a deeper look into modules Library > std=:format ● https://github.com/fmtlib/fmt is integrated into C++ ● Python like string formatting ● Define formatting rules for custom types fmt=:print("Hello, {}!", "world"); std=:string s = fmt=:format("I'd rather be {1} than {0}.", "right", "happy"); 5
  • 6. Overview of C++20 and a deeper look into modules Concurrency > std=:jthread ● A new kind of std=:thread ● Can automatically join ● Can be interrupted ○ std=:interrupt_token https://www.modernescpp.com/index.php/a-new-thread-with-c-20-std-jthread 6
  • 7. Overview of C++20 and a deeper look into modules Contracts int push(queue& q, int val) [[ expects: !q.full() ]] [[ ensures !q.empty() ]] { ==. [[assert: q.is_ok() ]] ==. } https://www.reddit.com/r/cpp/comments/cmk7ek/what_happened_to_c20_contracts/ 7 Precondition Postcondition Assertion
  • 8. Overview of C++20 and a deeper look into modules Concepts ● Extension of templates ○ specify which semantic categories are allowed ● Templates can be used more expressive ● Check types during compile time ○ “is sortable”, “is equality comparable”, … https://www.modernescpp.com/index.php/c-20-concepts-the-details 8
  • 9. Overview of C++20 and a deeper look into modules Coroutines ● Asynchronous programming ○ cooperative multitasking, event loops, ... ○ new keywords co_await and co_yield ==. size_t n = co_await socket.async_read_some(buffer(data)); co_await async_write(socket, buffer(data, n)); ==. https://en.cppreference.com/w/cpp/language/coroutines 9
  • 10. Overview of C++20 and a deeper look into modules Ranges ● Apply algorithms of STL on containers ○ connect them with pipe operator ● Use infinite data streams auto children_names = all_people | filter([](const auto& person) { return person.age < 14; }) | transform([](const auto& person) { return person.name; }) | to_vector; https://vector-of-bool.github.io/2019/10/21/rngs-static-ovr.html 10
  • 11. Overview of C++20 and a deeper look into modules Modules ● Alternative to header and implementation files ○ can halve the number of files in the code base ● No more include guards and/or #pragma once ○ But you can also separate between interface and implementation ● Faster compilation times?! ○ “Reduce build times due to not reparsing large header files” ■ https://gcc.gnu.org/wiki/cxx-modules ○ http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2019/p1441r1.pdf ● Isolation of preprocessor macros ● Better way to express which parts of a library are exported https://vector-of-bool.github.io/2019/03/10/modules-1.html 11
  • 12. Overview of C++20 and a deeper look into modules Modules > Names module-name: [module-name-qualifier] identifier ; module-name-qualifier: identifier "." | module-name-qualifier identifier "." ; => speech | speech.english 12
  • 13. Overview of C++20 and a deeper look into modules Modules > Declaration module-declaration: ["export"] "module" module-name [module-partition] [attribute-specifier-seq] ";" ; module-partition: ":" module-name ; => export module example; 13
  • 14. Overview of C++20 and a deeper look into modules Modules > Partitions and “Submodules” Partitions export module speech; export import :english; export import :spanish; “Submodules” → Separate modules export module speech; export import speech.english; export import speech.spanish; 14
  • 15. Overview of C++20 and a deeper look into modules Modules > Interfaces hello.cppm export module hello; export const char *greet() { return "Hello, world!"; } 15
  • 16. Overview of C++20 and a deeper look into modules Modules > Interfaces and Implementations hello.cppm export module hello; export const char *greet(); hello.cpp module hello; const char *greet() { return "Hello, world!"; } 16
  • 17. Overview of C++20 and a deeper look into modules Modules > What can be exported? ● namespace ● class ● struct ● non-static variables/constants ● ... Understanding C++ Modules: Part 2: export, import, visible, and reachable 17
  • 18. Overview of C++20 and a deeper look into modules Modules > Interoperability Every compiler uses it’s own binary format. You can not interchange the precompiled modules. https://www.reddit.com/r/cpp/comments/d5dxr3/do_c20_modules_have_a_st andard_binary_format_if/ 18
  • 19. Overview of C++20 and a deeper look into modules Compiler support TL;DR: WIP https://en.cppreference.com/w/cpp/compiler_support https://clang.llvm.org/cxx_status.html https://gcc.gnu.org/projects/cxx-status.html https://docs.microsoft.com/en-us/cpp/overview/visual-cpp-language-conform ance?view=vs-2019 19
  • 20. Overview of C++20 and a deeper look into modules Resources ● https://isocpp.org/ ● http://www.open-std.org/jtc1/sc22/wg21/docs/papers/ ● https://en.wikipedia.org/wiki/C%2B%2B20 ● https://www.reddit.com/r/cpp/comments/cfk9de/201907_cologne_iso_c_committee_trip_report_the/ ● https://docs.microsoft.com/en-us/cpp/cpp/cpp-language-reference ● https://en.cppreference.com/w/ ● https://vector-of-bool.github.io/ ● https://blog.panicsoftware.com/ ● http://modernescpp.com/ 20