SlideShare a Scribd company logo
1 of 114
Download to read offline
Timur Doumler
CoreHard Autumn Conference
30 November 2019
C++20:
The small things
@timur_audio
Version 1.4
we are here
11
1 Initialisation
2 Structured bindings
3 Lambdas
4 Templates
5 constexpr
6 Miscellaneous
12
1 Initialisation
2 Structured bindings
3 Lambdas
4 Templates
5 constexpr
6 Miscellaneous
Aggregates
13
struct Widget {
int a;
bool b;
int c;
};
Aggregates
14
struct Widget {
int a;
bool b;
int c;
};
int main() {
Widget widget = {3, true};
}
Designated initialisers
15
struct Widget {
int a;
bool b;
int c;
};
int main() {
Widget widget{.a = 3, .c = 7};
}
16
struct Widget {
int a;
bool b;
int c;
};
int main() {
Widget widget{.a = 3, .c = 7};
}
Only for aggregate types.
C compatibility feature.
Works like in C99, except:
• not out-of-order
Widget widget{.c = 7, .a = 3} // Error
• not nested
Widget widget{.c.e = 7} // Error
• not mixed with regular initialisers
Widget widget{.a = 3, 7} // Error
• not with arrays
int arr[3]{.[1] = 7} // Error
Designated initialisers
17
18
Aggregates can no longer declare constructors
19
struct Widget {
Widget() = delete;
};
Widget w1; // Error
Aggregates can no longer declare constructors
20
struct Widget {
Widget() = delete;
};
Widget w1; // Error
Widget w2{}; // OK in C++17!
Aggregates can no longer declare constructors
21
struct Widget {
Widget() = delete;
};
Widget w1; // Error
Widget w2{}; // OK in C++17! Will be error in C++20
Aggregates can no longer declare constructors
• Does not work with macros:
22
assert(Widget(2, 3)); // OK
C++17 problems with aggregate initialisation:
• Does not work with macros:
23
assert(Widget(2, 3)); // OK
assert(Widget{2, 3}); // Error: this breaks the preprocessor :(
C++17 problems with aggregate initialisation:
• Does not work with macros:
• Can’t do perfect forwarding in templates
• can’t write emplace or make_unique that works for aggregates :(
24
assert(Widget(2, 3)); // OK
assert(Widget{2, 3}); // Error: this breaks the preprocessor :(
C++17 problems with aggregate initialisation:
25
struct Widget {
int i;
int j;
};
Widget widget(1, 2); // will work in C++20!
C++20: Direct-initialisation of aggregates
26
struct Widget {
int i;
int j;
};
Widget widget(1, 2); // will work in C++20!
int arr[3](0, 1, 2); // will work in C++20!
C++20: Direct-initialisation of aggregates
27
struct Widget {
int i;
int j;
};
Widget widget(1, 2); // will work in C++20!
int arr[3](0, 1, 2); // will work in C++20!
So in C++20, (args) and {args} will do the same thing!
Except:
• () does not call std::initializer_list constructors
• {} does not allow narrowing conversions
C++20: Direct-initialisation of aggregates
28
struct Colour
{
Colour(int r, int g, int b) noexcept;
};
constinit
29
struct Colour
{
Colour(int r, int g, int b) noexcept;
};
namespace Colours
{
const Colour red = {255, 0, 0};
}
constinit
30
struct Colour
{
Colour(int r, int g, int b) noexcept;
};
namespace Colours
{
const Colour red = {255, 0, 0}; // dynamic initialisation
}
constinit
31
struct Colour
{
Colour(int r, int g, int b) noexcept;
};
namespace Colours
{
const Colour red = {255, 0, 0}; // dynamic initialisation
} // -> initialisation order fiasco -> UB :(
constinit
32
struct Colour
{
constexpr Colour(int r, int g, int b) noexcept;
};
namespace Colours
{
constexpr Colour red = {255, 0, 0};
}
constinit
33
struct Colour
{
constexpr Colour(int r, int g, int b) noexcept;
};
namespace Colours
{
constexpr Colour red = {255, 0, 0}; // constant initialisation :)
}
constinit
struct Colour
{
constexpr Colour(int r, int g, int b) noexcept;
};
namespace Colours
{
Colour backgroundColour = getBackgroundColour();
}
34
constinit
struct Colour
{
constexpr Colour(int r, int g, int b) noexcept;
};
namespace Colours
{
Colour backgroundColour = getBackgroundColour(); // const or dynamic init?
}
35
constinit
struct Colour
{
constexpr Colour(int r, int g, int b) noexcept;
};
namespace Colours
{
constinit Colour backgroundColour = getBackgroundColour();
}
36
constinit
37
constinit
struct Colour
{
constexpr Colour(int r, int g, int b) noexcept;
};
namespace Colours
{
constinit Colour backgroundColour = getBackgroundColour();
} // ^^^^^^ only compiles if init happens at compile time :)
Database getDatabase();
for (auto&& user : getDatabase().getUsers())
{
registerUser(user);
}
38
Range-based for with initialiser
C++17
Database getDatabase();
for (auto&& user : getDatabase().getUsers()) // maybe undefined behaviour!
{
registerUser(user);
}
39
Range-based for with initialiser
C++17
Database getDatabase();
auto db = getDatabase();
for (auto&& user : db.getUsers())
{
registerUser(user);
}
40
Range-based for with initialiser
C++17
Database getDatabase();
{
auto db = getDatabase();
for (auto&& user : db.getUsers())
{
registerUser(user);
}
}
41
Range-based for with initialiser
C++17
42
Range-based for with initialiser
Database getDatabase();
for (auto db = getDatabase(); auto&& user : db.getUsers())
{
registerUser(user);
}
C++20
43
1 Initialisation
2 Structured bindings
3 Lambdas
4 Templates
5 constexpr
6 Miscellaneous
44
struct Widget
{
int i;
bool b;
};
auto [a, b] = getWidget();
45
struct Widget
{
int i;
bool b;
};
auto [a, b] = getWidget();
static [a, b] = getWidget(); // Error in C++17
thread_local [a, b] = getWidget(); // Error in C++17
46
struct Widget
{
int i;
bool b;
};
auto [a, b] = getWidget();
static [a, b] = getWidget(); // OK in C++20
thread_local [a, b] = getWidget(); // OK in C++20
47
struct Widget
{
int i;
bool b;
};
auto [a, b] = getWidget();
auto f = [a]{ return a > 0; }; // Error in C++17:
// capture ‘a’ does not name a variable
48
struct Widget
{
int i;
bool b;
};
auto [a, b] = getWidget();
auto f = [a]{ return a > 0; }; // OK in C++20
49
struct Widget
{
int i;
bool b;
};
auto [a, b] = getWidget();
auto f = [a]{ return a > 0; }; // OK in C++20
// copies ‘a’, not the whole object
50
1 Initialisation
2 Structured bindings
3 Lambdas
4 Templates
5 constexpr
6 Miscellaneous
template<class F, class... Args>
auto delay_invoke(F f, Args... args) {
return [f = std::move(f), ...args = std::move(args)]() -> decltype(auto) {
return std::invoke(f, args...);
};
}
51
C++20: pack expansion allowed in lambda init capture
52
– Lambdas are allowed in unevaluated contexts
– Lambdas (without captures) are default-constructible
and assignable
More C++20 lambda features:
53
– Lambdas are allowed in unevaluated contexts
– Lambdas (without captures) are default-constructible
and assignable
More C++20 lambda features:
decltype([]{})
54
– Lambdas are allowed in unevaluated contexts
– Lambdas (without captures) are default-constructible
and assignable
More C++20 lambda features:
decltype([]{}) f;
55
– Lambdas are allowed in unevaluated contexts
– Lambdas (without captures) are default-constructible
and assignable
More C++20 lambda features:
class Widget
{
decltype([]{}) f;
};
56
template <typename T>
using MyPtr = std::unique_ptr<
T, decltype([](T* t) { myDeleter(t); })>;
MyPtr<Widget> ptr;
57
template <typename T>
using MyPtr = std::unique_ptr<
T, decltype([](T* t) { myDeleter(t); })>;
MyPtr<Widget> ptr;
using WidgetSet = std::set<
Widget,
decltype([](Widget& lhs, Widget& rhs) { return lhs.x < rhs.x; })>;
WidgetSet widgets;
58
Generic lambdas / functions
auto f = [](auto a){
return a * a;
};
59
auto f = [](auto a){
return a * a;
};
auto f(auto a) { // Generic *functions* – OK since C++20 :)
return a * a;
}
Generic lambdas / functions
60
template <typename T>
void f(std::vector<T> vector) {
// ...
}
Generic lambdas / functions
61
template <typename T>
void f(std::vector<T> vector) {
// ...
}
// C++20:
auto f = []<typename T>(std::vector<T> vector) {
// ...
};
Generic lambdas / functions
62
1 Initialisation
2 Structured bindings
3 Lambdas
4 Templates
5 constexpr
6 Miscellaneous
63
Non-type template parameters (NTTPs)
64
Non-type template parameters (NTTPs)
template <int size>
struct Widget
{
std::array<int, size> a;
};
65
Non-type template parameters (NTTPs)
template <int size>
struct Widget
{
std::array<int, size> a;
};
66
C++20: floating-point NTTPs
template <double x>
struct Filter
{
std::array<double, 2> coefficients = {x, 0.5 * x * x};
// stuff...
};
67
C++20: class-type NTTPs
struct Coefficients
{
double x;
double y;
};
68
C++20: class-type NTTPs
struct Coefficients
{
double x;
double y;
};
template <Coefficients coeffs>
struct Filter
{
// stuff :)
};
69
C++20: class-type NTTPs
struct Coefficients
{
double x;
double y;
};
template <Coefficients coeffs>
struct Filter
{
// stuff :)
};
constexpr Filter<Coefficients{1, 0.125}> f;
70
CTAD
71
CTAD
std::vector v = {1, 2, 3}; // std::vector<int>
72
CTAD
std::vector v = {1, 2, 3}; // std::vector<int>
std::tuple t = {42, 0.5, true}; // std::tuple<int, double, bool>
73
CTAD
std::vector v = {1, 2, 3}; // std::vector<int>
std::tuple t = {42, 0.5, true}; // std::tuple<int, double, bool>
std::scoped_lock lock(rtmutex); // std::scoped_lock<std::recursive_timed_mutex>
74
C++20 adds:
– CTAD for aggregates
– CTAD for alias templates
75
template <typename T, typename U>
struct aggr_pair
{
T t;
U u;
};
aggr_pair p = {1, true}; // Error: no deduction candidate found
C++17
76
template <typename T, typename U>
struct aggr_pair
{
T t;
U u;
};
template <typename T, typename U>
aggr_pair(T, U) -> aggr_pair<T, U>;
aggr_pair p = {1, true}; // OK
C++17
77
template <typename T, typename U>
struct aggr_pair
{
T t;
U u;
};
template <typename T, typename U>
aggr_pair(T, U) -> aggr_pair<T, U>;
aggr_pair p = {1, true}; // OK
C++17 C++20
template <typename T, typename U>
struct aggr_pair
{
T t;
U u;
};
aggr_pair p = {1, true}; // OK
78
template<typename... Bases>
struct overloaded : Bases...
{
using Bases::operator()...;
};
C++17
79
template<typename... Bases>
struct overloaded : Bases...
{
using Bases::operator()...;
};
template<typename... Bases>
overloaded(Bases...) -> overloaded<Bases...>;
C++17
80
template<typename... Bases>
struct overloaded : Bases...
{
using Bases::operator()...;
};
template<typename... Bases>
overloaded(Bases...) -> overloaded<Bases...>;
overloaded printer = {
[](auto arg) { std::cout << arg << ' '; },
[](double arg) { std::cout << std::fixed << arg << ' '; },
[](const char* arg) { std::cout << std::quoted(arg) << ' '; }
};
C++17
template<typename... Bases>
struct overloaded : Bases...
{
using Bases::operator()...;
};
template<typename... Bases>
overloaded(Bases...) -> overloaded<Bases...>;
overloaded printer = {
[](auto arg) { std::cout << arg << ' '; },
[](double arg) { std::cout << std::fixed << arg << ' '; },
[](const char* arg) { std::cout << std::quoted(arg) << ' '; }
};
int main()
{
printer("Hello, World!");
}
81
C++17
82
template<typename... Bases>
struct overloaded : Bases...
{
using Bases::operator()...;
};
template<typename... Bases>
overloaded(Bases...) -> overloaded<Bases...>;
overloaded printer = {
[](auto arg) { std::cout << arg << ' '; },
[](double arg) { std::cout << std::fixed << arg << ' '; },
[](const char* arg) { std::cout << std::quoted(arg) << ' '; }
};
int main()
{
printer("Hello, World!");
}
C++17
template<typename... Bases>
struct overloaded : Bases...
{
using Bases::operator()...;
};
overloaded printer = {
[](auto arg) { std::cout << arg << ' '; },
[](double arg) { std::cout << std::fixed << arg << ' '; },
[](const char* arg) { std::cout << std::quoted(arg) << ' '; }
};
int main()
{
printer("Hello, World!");
}
83
C++20
84
namespace pmr {
template <class T>
using vector = std::vector<T, std::pmr::polymorphic_allocator<T>>;
}
C++17
std::pmr::vector<int> v{1, 2, 3};
85
namespace pmr {
template <class T>
using vector = std::vector<T, std::pmr::polymorphic_allocator<T>>;
}
C++17 C++20
std::pmr::vector<int> v{1, 2, 3}; std::pmr::vector v{1, 2, 3};
86
1 Initialisation
2 Structured bindings
3 Lambdas
4 Templates
5 constexpr
6 Miscellaneous
87
In C++20, in a constexpr function you can:
– have a try-block
– have an unevaluated asm block
– use a union
– call virtual functions
– dynamic_cast and typeid
– new and delete
88
Daveed Vandevoorde
“C++ Constants”
C++Now 2019 keynote
Louis Dionne
"Compile-time programming and
reflection in C++20 and beyond”
CppCon 2018 talk
89
“running” code at compile time
int square(int i) {
return i * i;
}
90
“running” code at compile time
constexpr int square(int i) {
return i * i;
}
square(3); // compile time
square(x); // runtime
consteval int square(int i) {
return i * i;
}
square(3); // compile time
square(x); // Error - x is not a compile-time constant!
91
“running” code at compile time
92
compile time or runtime?
int square(int i) {
return __magic_fast_square(i); // contains runtime magic
}
square(3); // runtime, fast magic
square(x); // runtime, fast magic
93
compile time or runtime?
constexpr int square(int i) {
return i * i;
}
square(3); // compile time
square(x); // runtime, no fast magic :(
94
compile time or runtime?
constexpr int square(int i) {
if (std::is_constant_evaluated()) {
return i * i;
}
else {
return __magic_fast_square(i);
}
}
square(3); // compile time
square(x); // runtime, fast magic :)
constexpr int square(int i) {
if (std::is_constant_evaluated()) {
return i * i;
}
else {
return __magic_fast_square(i);
}
}
square(3); // compile time
square(x); // runtime, fast magic :)
95
compile time or runtime?
96
1 Initialisation
2 Structured bindings
3 Lambdas
4 Templates
5 constexpr
6 Miscellaneous
97
template <typename Container>
auto findFirstValid(const Container& c) -> Container::iterator
{
return std::find_if(c.begin(), c.end(), [](auto elem){ return elem.is_valid(); });
}
98
template <typename Container>
auto findFirstValid(const Container& c) -> Container::const_iterator
{
return std::find_if(c.begin(), c.end(), [](auto elem){ return elem.is_valid(); });
}
// Error: missing 'typename' prior to dependent type name ‘Container::const_iterator'
99
template <typename Container>
auto findFirstValid(const Container& c) -> Container::const_iterator
{
return std::find_if(c.begin(), c.end(), [](auto elem){ return elem.is_valid(); });
}
// OK in C++20 :)
100
New attributes in C++20
101
– [[likely]], [[unlikely]]
New attributes in C++20
102
– [[likely]], [[unlikely]]
– [[no_unique_address]]
New attributes in C++20
103
– [[likely]], [[unlikely]]
– [[no_unique_address]]
– [[nodiscard]] on constructors
New attributes in C++20
104
– [[likely]], [[unlikely]]
– [[no_unique_address]]
– [[nodiscard]] on constructors
– [[nodiscard(“can have a message”)]]
New attributes in C++20
enum class rgba_color_channel {
red,
green,
blue,
alpha
};
105
Using enum
enum class rgba_color_channel {
red,
green,
blue,
alpha
};
std::string_view to_string(rgba_color_channel channel) {
switch (channel) {
case rgba_color_channel::red: return "red";
case rgba_color_channel::green: return "green";
case rgba_color_channel::blue: return "blue";
case rgba_color_channel::alpha: return "alpha";
}
}
106
Using enum
107
Using enum
enum class rgba_color_channel {
red,
green,
blue,
alpha
};
std::string_view to_string(rgba_color_channel channel) {
switch (channel) {
case rgba_color_channel::red: return "red";
case rgba_color_channel::green: return "green";
case rgba_color_channel::blue: return "blue";
case rgba_color_channel::alpha: return "alpha";
}
}
enum class rgba_color_channel {
red,
green,
blue,
alpha
};
std::string_view to_string(rgba_color_channel channel) {
switch (channel) {
using enum rgba_color_channel;
case red: return "red";
case green: return "green";
case blue: return "blue";
case alpha: return "alpha";
}
}
108
Using enum
enum class Suit {
diamonds,
hearts,
spades,
clubs
};
class Card {
using enum Suit;
Suit suit = spades;
};
109
Using enum
110
Built-in UTF-8 char type
int main() {
const char* str = u8" 🦄 🌈"; // C++17...
}
111
Built-in UTF-8 char type
int main() {
const char* str = u8" 🦄 🌈"; // compile error in C++20!
}
int main() {
const char8_t* str = u8" 🦄 🌈";
}
112
Built-in UTF-8 char type
we are here
Timur Doumler
CoreHard Autumn Conference
30 November 2019
C++20:
The small things
@timur_audio
Version 1.4

More Related Content

What's hot

Kernel Recipes 2017 - Understanding the Linux kernel via ftrace - Steven Rostedt
Kernel Recipes 2017 - Understanding the Linux kernel via ftrace - Steven RostedtKernel Recipes 2017 - Understanding the Linux kernel via ftrace - Steven Rostedt
Kernel Recipes 2017 - Understanding the Linux kernel via ftrace - Steven RostedtAnne Nicolas
 
LLVM Backend Porting
LLVM Backend PortingLLVM Backend Porting
LLVM Backend PortingShiva Chen
 
Approaching zero driver overhead
Approaching zero driver overheadApproaching zero driver overhead
Approaching zero driver overheadCass Everitt
 
We Love Performance! How Tic Toc Games Uses ECS in Mobile Puzzle Games
We Love Performance! How Tic Toc Games Uses ECS in Mobile Puzzle GamesWe Love Performance! How Tic Toc Games Uses ECS in Mobile Puzzle Games
We Love Performance! How Tic Toc Games Uses ECS in Mobile Puzzle GamesUnity Technologies
 
libuv, NodeJS and everything in between
libuv, NodeJS and everything in betweenlibuv, NodeJS and everything in between
libuv, NodeJS and everything in betweenSaúl Ibarra Corretgé
 
잘 알려지지 않은 숨은 진주, Winsock API - WSAPoll, Fast Loopback
잘 알려지지 않은 숨은 진주, Winsock API - WSAPoll, Fast Loopback잘 알려지지 않은 숨은 진주, Winsock API - WSAPoll, Fast Loopback
잘 알려지지 않은 숨은 진주, Winsock API - WSAPoll, Fast Loopback흥배 최
 
Kotlin coroutine - behind the scenes
Kotlin coroutine - behind the scenesKotlin coroutine - behind the scenes
Kotlin coroutine - behind the scenesAnh Vu
 
Java Deserialization Vulnerabilities - The Forgotten Bug Class (DeepSec Edition)
Java Deserialization Vulnerabilities - The Forgotten Bug Class (DeepSec Edition)Java Deserialization Vulnerabilities - The Forgotten Bug Class (DeepSec Edition)
Java Deserialization Vulnerabilities - The Forgotten Bug Class (DeepSec Edition)CODE WHITE GmbH
 
LLVM Register Allocation
LLVM Register AllocationLLVM Register Allocation
LLVM Register AllocationWang Hsiangkai
 
Parallel Futures of a Game Engine
Parallel Futures of a Game EngineParallel Futures of a Game Engine
Parallel Futures of a Game EngineJohan Andersson
 
Refelction의 개념과 RTTR 라이브러리
Refelction의 개념과 RTTR 라이브러리Refelction의 개념과 RTTR 라이브러리
Refelction의 개념과 RTTR 라이브러리ssuser7c5a40
 
Data oriented design and c++
Data oriented design and c++Data oriented design and c++
Data oriented design and c++Mike Acton
 
[嵌入式系統] 嵌入式系統進階
[嵌入式系統] 嵌入式系統進階[嵌入式系統] 嵌入式系統進階
[嵌入式系統] 嵌入式系統進階Simen Li
 
C++ 프로젝트에 단위 테스트 도입하기
C++ 프로젝트에 단위 테스트 도입하기C++ 프로젝트에 단위 테스트 도입하기
C++ 프로젝트에 단위 테스트 도입하기OnGameServer
 
In-Depth Model/View with QML
In-Depth Model/View with QMLIn-Depth Model/View with QML
In-Depth Model/View with QMLICS
 
JavaScriptCore.framework の普通な使い方 #cocoa_kansai
JavaScriptCore.framework の普通な使い方 #cocoa_kansaiJavaScriptCore.framework の普通な使い方 #cocoa_kansai
JavaScriptCore.framework の普通な使い方 #cocoa_kansaiTomohiro Kumagai
 
Modern C++ 프로그래머를 위한 CPP11/14 핵심
Modern C++ 프로그래머를 위한 CPP11/14 핵심Modern C++ 프로그래머를 위한 CPP11/14 핵심
Modern C++ 프로그래머를 위한 CPP11/14 핵심흥배 최
 

What's hot (20)

Kernel Recipes 2017 - Understanding the Linux kernel via ftrace - Steven Rostedt
Kernel Recipes 2017 - Understanding the Linux kernel via ftrace - Steven RostedtKernel Recipes 2017 - Understanding the Linux kernel via ftrace - Steven Rostedt
Kernel Recipes 2017 - Understanding the Linux kernel via ftrace - Steven Rostedt
 
LLVM Backend Porting
LLVM Backend PortingLLVM Backend Porting
LLVM Backend Porting
 
Approaching zero driver overhead
Approaching zero driver overheadApproaching zero driver overhead
Approaching zero driver overhead
 
We Love Performance! How Tic Toc Games Uses ECS in Mobile Puzzle Games
We Love Performance! How Tic Toc Games Uses ECS in Mobile Puzzle GamesWe Love Performance! How Tic Toc Games Uses ECS in Mobile Puzzle Games
We Love Performance! How Tic Toc Games Uses ECS in Mobile Puzzle Games
 
A Step Towards Data Orientation
A Step Towards Data OrientationA Step Towards Data Orientation
A Step Towards Data Orientation
 
libuv, NodeJS and everything in between
libuv, NodeJS and everything in betweenlibuv, NodeJS and everything in between
libuv, NodeJS and everything in between
 
잘 알려지지 않은 숨은 진주, Winsock API - WSAPoll, Fast Loopback
잘 알려지지 않은 숨은 진주, Winsock API - WSAPoll, Fast Loopback잘 알려지지 않은 숨은 진주, Winsock API - WSAPoll, Fast Loopback
잘 알려지지 않은 숨은 진주, Winsock API - WSAPoll, Fast Loopback
 
Kotlin coroutine - behind the scenes
Kotlin coroutine - behind the scenesKotlin coroutine - behind the scenes
Kotlin coroutine - behind the scenes
 
Java Deserialization Vulnerabilities - The Forgotten Bug Class (DeepSec Edition)
Java Deserialization Vulnerabilities - The Forgotten Bug Class (DeepSec Edition)Java Deserialization Vulnerabilities - The Forgotten Bug Class (DeepSec Edition)
Java Deserialization Vulnerabilities - The Forgotten Bug Class (DeepSec Edition)
 
LLVM Register Allocation
LLVM Register AllocationLLVM Register Allocation
LLVM Register Allocation
 
Parallel Futures of a Game Engine
Parallel Futures of a Game EngineParallel Futures of a Game Engine
Parallel Futures of a Game Engine
 
Refelction의 개념과 RTTR 라이브러리
Refelction의 개념과 RTTR 라이브러리Refelction의 개념과 RTTR 라이브러리
Refelction의 개념과 RTTR 라이브러리
 
Python_ 3 CheatSheet
Python_ 3 CheatSheetPython_ 3 CheatSheet
Python_ 3 CheatSheet
 
Data oriented design and c++
Data oriented design and c++Data oriented design and c++
Data oriented design and c++
 
[嵌入式系統] 嵌入式系統進階
[嵌入式系統] 嵌入式系統進階[嵌入式系統] 嵌入式系統進階
[嵌入式系統] 嵌入式系統進階
 
C++ 프로젝트에 단위 테스트 도입하기
C++ 프로젝트에 단위 테스트 도입하기C++ 프로젝트에 단위 테스트 도입하기
C++ 프로젝트에 단위 테스트 도입하기
 
Xvisor: embedded and lightweight hypervisor
Xvisor: embedded and lightweight hypervisorXvisor: embedded and lightweight hypervisor
Xvisor: embedded and lightweight hypervisor
 
In-Depth Model/View with QML
In-Depth Model/View with QMLIn-Depth Model/View with QML
In-Depth Model/View with QML
 
JavaScriptCore.framework の普通な使い方 #cocoa_kansai
JavaScriptCore.framework の普通な使い方 #cocoa_kansaiJavaScriptCore.framework の普通な使い方 #cocoa_kansai
JavaScriptCore.framework の普通な使い方 #cocoa_kansai
 
Modern C++ 프로그래머를 위한 CPP11/14 핵심
Modern C++ 프로그래머를 위한 CPP11/14 핵심Modern C++ 프로그래머를 위한 CPP11/14 핵심
Modern C++ 프로그래머를 위한 CPP11/14 핵심
 

Similar to C++20: The small things - CoreHard Autumn Conference

Whats new in_csharp4
Whats new in_csharp4Whats new in_csharp4
Whats new in_csharp4Abed Bukhari
 
COSCUP2023 RSA256 Verilator.pdf
COSCUP2023 RSA256 Verilator.pdfCOSCUP2023 RSA256 Verilator.pdf
COSCUP2023 RSA256 Verilator.pdfYodalee
 
Applying Compiler Techniques to Iterate At Blazing Speed
Applying Compiler Techniques to Iterate At Blazing SpeedApplying Compiler Techniques to Iterate At Blazing Speed
Applying Compiler Techniques to Iterate At Blazing SpeedPascal-Louis Perez
 
C++ amp on linux
C++ amp on linuxC++ amp on linux
C++ amp on linuxMiller Lee
 
C++ 11 Features
C++ 11 FeaturesC++ 11 Features
C++ 11 FeaturesJan Rüegg
 
How to Adopt Modern C++17 into Your C++ Code
How to Adopt Modern C++17 into Your C++ CodeHow to Adopt Modern C++17 into Your C++ Code
How to Adopt Modern C++17 into Your C++ CodeMicrosoft Tech Community
 
How to Adopt Modern C++17 into Your C++ Code
How to Adopt Modern C++17 into Your C++ CodeHow to Adopt Modern C++17 into Your C++ Code
How to Adopt Modern C++17 into Your C++ CodeMicrosoft Tech Community
 
Analysis of Haiku Operating System (BeOS Family) by PVS-Studio. Part 2
Analysis of Haiku Operating System (BeOS Family) by PVS-Studio. Part 2Analysis of Haiku Operating System (BeOS Family) by PVS-Studio. Part 2
Analysis of Haiku Operating System (BeOS Family) by PVS-Studio. Part 2PVS-Studio
 
Java 5 6 Generics, Concurrency, Garbage Collection, Tuning
Java 5 6 Generics, Concurrency, Garbage Collection, TuningJava 5 6 Generics, Concurrency, Garbage Collection, Tuning
Java 5 6 Generics, Concurrency, Garbage Collection, TuningCarol McDonald
 
20145-5SumII_CSC407_assign1.htmlCSC 407 Computer Systems II.docx
20145-5SumII_CSC407_assign1.htmlCSC 407 Computer Systems II.docx20145-5SumII_CSC407_assign1.htmlCSC 407 Computer Systems II.docx
20145-5SumII_CSC407_assign1.htmlCSC 407 Computer Systems II.docxeugeniadean34240
 
Analysis of Microsoft Code Contracts
Analysis of Microsoft Code ContractsAnalysis of Microsoft Code Contracts
Analysis of Microsoft Code ContractsPVS-Studio
 
data Structure Lecture 1
data Structure Lecture 1data Structure Lecture 1
data Structure Lecture 1Teksify
 
.gradle 파일 정독해보기
.gradle 파일 정독해보기.gradle 파일 정독해보기
.gradle 파일 정독해보기경주 전
 
Introduction to cython: example of GCoptimization
Introduction to cython: example of GCoptimizationIntroduction to cython: example of GCoptimization
Introduction to cython: example of GCoptimizationKevin Keraudren
 
LDCQ paper Dec21 with answer key_62cb2996afc60f6aedeb248c1d9283e5.pdf
LDCQ paper Dec21 with answer key_62cb2996afc60f6aedeb248c1d9283e5.pdfLDCQ paper Dec21 with answer key_62cb2996afc60f6aedeb248c1d9283e5.pdf
LDCQ paper Dec21 with answer key_62cb2996afc60f6aedeb248c1d9283e5.pdfVedant Gavhane
 

Similar to C++20: The small things - CoreHard Autumn Conference (20)

Whats new in_csharp4
Whats new in_csharp4Whats new in_csharp4
Whats new in_csharp4
 
COSCUP2023 RSA256 Verilator.pdf
COSCUP2023 RSA256 Verilator.pdfCOSCUP2023 RSA256 Verilator.pdf
COSCUP2023 RSA256 Verilator.pdf
 
Java Generics
Java GenericsJava Generics
Java Generics
 
Applying Compiler Techniques to Iterate At Blazing Speed
Applying Compiler Techniques to Iterate At Blazing SpeedApplying Compiler Techniques to Iterate At Blazing Speed
Applying Compiler Techniques to Iterate At Blazing Speed
 
C++ amp on linux
C++ amp on linuxC++ amp on linux
C++ amp on linux
 
C++ 11 Features
C++ 11 FeaturesC++ 11 Features
C++ 11 Features
 
How to Adopt Modern C++17 into Your C++ Code
How to Adopt Modern C++17 into Your C++ CodeHow to Adopt Modern C++17 into Your C++ Code
How to Adopt Modern C++17 into Your C++ Code
 
How to Adopt Modern C++17 into Your C++ Code
How to Adopt Modern C++17 into Your C++ CodeHow to Adopt Modern C++17 into Your C++ Code
How to Adopt Modern C++17 into Your C++ Code
 
Analysis of Haiku Operating System (BeOS Family) by PVS-Studio. Part 2
Analysis of Haiku Operating System (BeOS Family) by PVS-Studio. Part 2Analysis of Haiku Operating System (BeOS Family) by PVS-Studio. Part 2
Analysis of Haiku Operating System (BeOS Family) by PVS-Studio. Part 2
 
Boosting Developer Productivity with Clang
Boosting Developer Productivity with ClangBoosting Developer Productivity with Clang
Boosting Developer Productivity with Clang
 
Lecture5
Lecture5Lecture5
Lecture5
 
C# 6.0 Preview
C# 6.0 PreviewC# 6.0 Preview
C# 6.0 Preview
 
Java 5 6 Generics, Concurrency, Garbage Collection, Tuning
Java 5 6 Generics, Concurrency, Garbage Collection, TuningJava 5 6 Generics, Concurrency, Garbage Collection, Tuning
Java 5 6 Generics, Concurrency, Garbage Collection, Tuning
 
20145-5SumII_CSC407_assign1.htmlCSC 407 Computer Systems II.docx
20145-5SumII_CSC407_assign1.htmlCSC 407 Computer Systems II.docx20145-5SumII_CSC407_assign1.htmlCSC 407 Computer Systems II.docx
20145-5SumII_CSC407_assign1.htmlCSC 407 Computer Systems II.docx
 
Cpp tutorial
Cpp tutorialCpp tutorial
Cpp tutorial
 
Analysis of Microsoft Code Contracts
Analysis of Microsoft Code ContractsAnalysis of Microsoft Code Contracts
Analysis of Microsoft Code Contracts
 
data Structure Lecture 1
data Structure Lecture 1data Structure Lecture 1
data Structure Lecture 1
 
.gradle 파일 정독해보기
.gradle 파일 정독해보기.gradle 파일 정독해보기
.gradle 파일 정독해보기
 
Introduction to cython: example of GCoptimization
Introduction to cython: example of GCoptimizationIntroduction to cython: example of GCoptimization
Introduction to cython: example of GCoptimization
 
LDCQ paper Dec21 with answer key_62cb2996afc60f6aedeb248c1d9283e5.pdf
LDCQ paper Dec21 with answer key_62cb2996afc60f6aedeb248c1d9283e5.pdfLDCQ paper Dec21 with answer key_62cb2996afc60f6aedeb248c1d9283e5.pdf
LDCQ paper Dec21 with answer key_62cb2996afc60f6aedeb248c1d9283e5.pdf
 

More from corehard_by

C++ CoreHard Autumn 2018. Создание пакетов для открытых библиотек через conan...
C++ CoreHard Autumn 2018. Создание пакетов для открытых библиотек через conan...C++ CoreHard Autumn 2018. Создание пакетов для открытых библиотек через conan...
C++ CoreHard Autumn 2018. Создание пакетов для открытых библиотек через conan...corehard_by
 
C++ CoreHard Autumn 2018. Что должен знать каждый C++ программист или Как про...
C++ CoreHard Autumn 2018. Что должен знать каждый C++ программист или Как про...C++ CoreHard Autumn 2018. Что должен знать каждый C++ программист или Как про...
C++ CoreHard Autumn 2018. Что должен знать каждый C++ программист или Как про...corehard_by
 
C++ CoreHard Autumn 2018. Actors vs CSP vs Tasks vs ... - Евгений Охотников
C++ CoreHard Autumn 2018. Actors vs CSP vs Tasks vs ... - Евгений ОхотниковC++ CoreHard Autumn 2018. Actors vs CSP vs Tasks vs ... - Евгений Охотников
C++ CoreHard Autumn 2018. Actors vs CSP vs Tasks vs ... - Евгений Охотниковcorehard_by
 
C++ CoreHard Autumn 2018. Знай свое "железо": иерархия памяти - Александр Титов
C++ CoreHard Autumn 2018. Знай свое "железо": иерархия памяти - Александр ТитовC++ CoreHard Autumn 2018. Знай свое "железо": иерархия памяти - Александр Титов
C++ CoreHard Autumn 2018. Знай свое "железо": иерархия памяти - Александр Титовcorehard_by
 
C++ CoreHard Autumn 2018. Информационная безопасность и разработка ПО - Евген...
C++ CoreHard Autumn 2018. Информационная безопасность и разработка ПО - Евген...C++ CoreHard Autumn 2018. Информационная безопасность и разработка ПО - Евген...
C++ CoreHard Autumn 2018. Информационная безопасность и разработка ПО - Евген...corehard_by
 
C++ CoreHard Autumn 2018. Заглядываем под капот «Поясов по C++» - Илья Шишков
C++ CoreHard Autumn 2018. Заглядываем под капот «Поясов по C++» - Илья ШишковC++ CoreHard Autumn 2018. Заглядываем под капот «Поясов по C++» - Илья Шишков
C++ CoreHard Autumn 2018. Заглядываем под капот «Поясов по C++» - Илья Шишковcorehard_by
 
C++ CoreHard Autumn 2018. Ускорение сборки C++ проектов, способы и последстви...
C++ CoreHard Autumn 2018. Ускорение сборки C++ проектов, способы и последстви...C++ CoreHard Autumn 2018. Ускорение сборки C++ проектов, способы и последстви...
C++ CoreHard Autumn 2018. Ускорение сборки C++ проектов, способы и последстви...corehard_by
 
C++ CoreHard Autumn 2018. Метаклассы: воплощаем мечты в реальность - Сергей С...
C++ CoreHard Autumn 2018. Метаклассы: воплощаем мечты в реальность - Сергей С...C++ CoreHard Autumn 2018. Метаклассы: воплощаем мечты в реальность - Сергей С...
C++ CoreHard Autumn 2018. Метаклассы: воплощаем мечты в реальность - Сергей С...corehard_by
 
C++ CoreHard Autumn 2018. Что не умеет оптимизировать компилятор - Александр ...
C++ CoreHard Autumn 2018. Что не умеет оптимизировать компилятор - Александр ...C++ CoreHard Autumn 2018. Что не умеет оптимизировать компилятор - Александр ...
C++ CoreHard Autumn 2018. Что не умеет оптимизировать компилятор - Александр ...corehard_by
 
C++ CoreHard Autumn 2018. Кодогенерация C++ кроссплатформенно. Продолжение - ...
C++ CoreHard Autumn 2018. Кодогенерация C++ кроссплатформенно. Продолжение - ...C++ CoreHard Autumn 2018. Кодогенерация C++ кроссплатформенно. Продолжение - ...
C++ CoreHard Autumn 2018. Кодогенерация C++ кроссплатформенно. Продолжение - ...corehard_by
 
C++ CoreHard Autumn 2018. Concurrency and Parallelism in C++17 and C++20/23 -...
C++ CoreHard Autumn 2018. Concurrency and Parallelism in C++17 and C++20/23 -...C++ CoreHard Autumn 2018. Concurrency and Parallelism in C++17 and C++20/23 -...
C++ CoreHard Autumn 2018. Concurrency and Parallelism in C++17 and C++20/23 -...corehard_by
 
C++ CoreHard Autumn 2018. Обработка списков на C++ в функциональном стиле - В...
C++ CoreHard Autumn 2018. Обработка списков на C++ в функциональном стиле - В...C++ CoreHard Autumn 2018. Обработка списков на C++ в функциональном стиле - В...
C++ CoreHard Autumn 2018. Обработка списков на C++ в функциональном стиле - В...corehard_by
 
C++ Corehard Autumn 2018. Обучаем на Python, применяем на C++ - Павел Филонов
C++ Corehard Autumn 2018. Обучаем на Python, применяем на C++ - Павел ФилоновC++ Corehard Autumn 2018. Обучаем на Python, применяем на C++ - Павел Филонов
C++ Corehard Autumn 2018. Обучаем на Python, применяем на C++ - Павел Филоновcorehard_by
 
C++ CoreHard Autumn 2018. Asynchronous programming with ranges - Ivan Čukić
C++ CoreHard Autumn 2018. Asynchronous programming with ranges - Ivan ČukićC++ CoreHard Autumn 2018. Asynchronous programming with ranges - Ivan Čukić
C++ CoreHard Autumn 2018. Asynchronous programming with ranges - Ivan Čukićcorehard_by
 
C++ CoreHard Autumn 2018. Debug C++ Without Running - Anastasia Kazakova
C++ CoreHard Autumn 2018. Debug C++ Without Running - Anastasia KazakovaC++ CoreHard Autumn 2018. Debug C++ Without Running - Anastasia Kazakova
C++ CoreHard Autumn 2018. Debug C++ Without Running - Anastasia Kazakovacorehard_by
 
C++ CoreHard Autumn 2018. Полезный constexpr - Антон Полухин
C++ CoreHard Autumn 2018. Полезный constexpr - Антон ПолухинC++ CoreHard Autumn 2018. Полезный constexpr - Антон Полухин
C++ CoreHard Autumn 2018. Полезный constexpr - Антон Полухинcorehard_by
 
C++ CoreHard Autumn 2018. Text Formatting For a Future Range-Based Standard L...
C++ CoreHard Autumn 2018. Text Formatting For a Future Range-Based Standard L...C++ CoreHard Autumn 2018. Text Formatting For a Future Range-Based Standard L...
C++ CoreHard Autumn 2018. Text Formatting For a Future Range-Based Standard L...corehard_by
 
Исключительная модель памяти. Алексей Ткаченко ➠ CoreHard Autumn 2019
Исключительная модель памяти. Алексей Ткаченко ➠ CoreHard Autumn 2019Исключительная модель памяти. Алексей Ткаченко ➠ CoreHard Autumn 2019
Исключительная модель памяти. Алексей Ткаченко ➠ CoreHard Autumn 2019corehard_by
 
Как помочь и как помешать компилятору. Андрей Олейников ➠ CoreHard Autumn 2019
Как помочь и как помешать компилятору. Андрей Олейников ➠  CoreHard Autumn 2019Как помочь и как помешать компилятору. Андрей Олейников ➠  CoreHard Autumn 2019
Как помочь и как помешать компилятору. Андрей Олейников ➠ CoreHard Autumn 2019corehard_by
 
Автоматизируй это. Кирилл Тихонов ➠ CoreHard Autumn 2019
Автоматизируй это. Кирилл Тихонов ➠  CoreHard Autumn 2019Автоматизируй это. Кирилл Тихонов ➠  CoreHard Autumn 2019
Автоматизируй это. Кирилл Тихонов ➠ CoreHard Autumn 2019corehard_by
 

More from corehard_by (20)

C++ CoreHard Autumn 2018. Создание пакетов для открытых библиотек через conan...
C++ CoreHard Autumn 2018. Создание пакетов для открытых библиотек через conan...C++ CoreHard Autumn 2018. Создание пакетов для открытых библиотек через conan...
C++ CoreHard Autumn 2018. Создание пакетов для открытых библиотек через conan...
 
C++ CoreHard Autumn 2018. Что должен знать каждый C++ программист или Как про...
C++ CoreHard Autumn 2018. Что должен знать каждый C++ программист или Как про...C++ CoreHard Autumn 2018. Что должен знать каждый C++ программист или Как про...
C++ CoreHard Autumn 2018. Что должен знать каждый C++ программист или Как про...
 
C++ CoreHard Autumn 2018. Actors vs CSP vs Tasks vs ... - Евгений Охотников
C++ CoreHard Autumn 2018. Actors vs CSP vs Tasks vs ... - Евгений ОхотниковC++ CoreHard Autumn 2018. Actors vs CSP vs Tasks vs ... - Евгений Охотников
C++ CoreHard Autumn 2018. Actors vs CSP vs Tasks vs ... - Евгений Охотников
 
C++ CoreHard Autumn 2018. Знай свое "железо": иерархия памяти - Александр Титов
C++ CoreHard Autumn 2018. Знай свое "железо": иерархия памяти - Александр ТитовC++ CoreHard Autumn 2018. Знай свое "железо": иерархия памяти - Александр Титов
C++ CoreHard Autumn 2018. Знай свое "железо": иерархия памяти - Александр Титов
 
C++ CoreHard Autumn 2018. Информационная безопасность и разработка ПО - Евген...
C++ CoreHard Autumn 2018. Информационная безопасность и разработка ПО - Евген...C++ CoreHard Autumn 2018. Информационная безопасность и разработка ПО - Евген...
C++ CoreHard Autumn 2018. Информационная безопасность и разработка ПО - Евген...
 
C++ CoreHard Autumn 2018. Заглядываем под капот «Поясов по C++» - Илья Шишков
C++ CoreHard Autumn 2018. Заглядываем под капот «Поясов по C++» - Илья ШишковC++ CoreHard Autumn 2018. Заглядываем под капот «Поясов по C++» - Илья Шишков
C++ CoreHard Autumn 2018. Заглядываем под капот «Поясов по C++» - Илья Шишков
 
C++ CoreHard Autumn 2018. Ускорение сборки C++ проектов, способы и последстви...
C++ CoreHard Autumn 2018. Ускорение сборки C++ проектов, способы и последстви...C++ CoreHard Autumn 2018. Ускорение сборки C++ проектов, способы и последстви...
C++ CoreHard Autumn 2018. Ускорение сборки C++ проектов, способы и последстви...
 
C++ CoreHard Autumn 2018. Метаклассы: воплощаем мечты в реальность - Сергей С...
C++ CoreHard Autumn 2018. Метаклассы: воплощаем мечты в реальность - Сергей С...C++ CoreHard Autumn 2018. Метаклассы: воплощаем мечты в реальность - Сергей С...
C++ CoreHard Autumn 2018. Метаклассы: воплощаем мечты в реальность - Сергей С...
 
C++ CoreHard Autumn 2018. Что не умеет оптимизировать компилятор - Александр ...
C++ CoreHard Autumn 2018. Что не умеет оптимизировать компилятор - Александр ...C++ CoreHard Autumn 2018. Что не умеет оптимизировать компилятор - Александр ...
C++ CoreHard Autumn 2018. Что не умеет оптимизировать компилятор - Александр ...
 
C++ CoreHard Autumn 2018. Кодогенерация C++ кроссплатформенно. Продолжение - ...
C++ CoreHard Autumn 2018. Кодогенерация C++ кроссплатформенно. Продолжение - ...C++ CoreHard Autumn 2018. Кодогенерация C++ кроссплатформенно. Продолжение - ...
C++ CoreHard Autumn 2018. Кодогенерация C++ кроссплатформенно. Продолжение - ...
 
C++ CoreHard Autumn 2018. Concurrency and Parallelism in C++17 and C++20/23 -...
C++ CoreHard Autumn 2018. Concurrency and Parallelism in C++17 and C++20/23 -...C++ CoreHard Autumn 2018. Concurrency and Parallelism in C++17 and C++20/23 -...
C++ CoreHard Autumn 2018. Concurrency and Parallelism in C++17 and C++20/23 -...
 
C++ CoreHard Autumn 2018. Обработка списков на C++ в функциональном стиле - В...
C++ CoreHard Autumn 2018. Обработка списков на C++ в функциональном стиле - В...C++ CoreHard Autumn 2018. Обработка списков на C++ в функциональном стиле - В...
C++ CoreHard Autumn 2018. Обработка списков на C++ в функциональном стиле - В...
 
C++ Corehard Autumn 2018. Обучаем на Python, применяем на C++ - Павел Филонов
C++ Corehard Autumn 2018. Обучаем на Python, применяем на C++ - Павел ФилоновC++ Corehard Autumn 2018. Обучаем на Python, применяем на C++ - Павел Филонов
C++ Corehard Autumn 2018. Обучаем на Python, применяем на C++ - Павел Филонов
 
C++ CoreHard Autumn 2018. Asynchronous programming with ranges - Ivan Čukić
C++ CoreHard Autumn 2018. Asynchronous programming with ranges - Ivan ČukićC++ CoreHard Autumn 2018. Asynchronous programming with ranges - Ivan Čukić
C++ CoreHard Autumn 2018. Asynchronous programming with ranges - Ivan Čukić
 
C++ CoreHard Autumn 2018. Debug C++ Without Running - Anastasia Kazakova
C++ CoreHard Autumn 2018. Debug C++ Without Running - Anastasia KazakovaC++ CoreHard Autumn 2018. Debug C++ Without Running - Anastasia Kazakova
C++ CoreHard Autumn 2018. Debug C++ Without Running - Anastasia Kazakova
 
C++ CoreHard Autumn 2018. Полезный constexpr - Антон Полухин
C++ CoreHard Autumn 2018. Полезный constexpr - Антон ПолухинC++ CoreHard Autumn 2018. Полезный constexpr - Антон Полухин
C++ CoreHard Autumn 2018. Полезный constexpr - Антон Полухин
 
C++ CoreHard Autumn 2018. Text Formatting For a Future Range-Based Standard L...
C++ CoreHard Autumn 2018. Text Formatting For a Future Range-Based Standard L...C++ CoreHard Autumn 2018. Text Formatting For a Future Range-Based Standard L...
C++ CoreHard Autumn 2018. Text Formatting For a Future Range-Based Standard L...
 
Исключительная модель памяти. Алексей Ткаченко ➠ CoreHard Autumn 2019
Исключительная модель памяти. Алексей Ткаченко ➠ CoreHard Autumn 2019Исключительная модель памяти. Алексей Ткаченко ➠ CoreHard Autumn 2019
Исключительная модель памяти. Алексей Ткаченко ➠ CoreHard Autumn 2019
 
Как помочь и как помешать компилятору. Андрей Олейников ➠ CoreHard Autumn 2019
Как помочь и как помешать компилятору. Андрей Олейников ➠  CoreHard Autumn 2019Как помочь и как помешать компилятору. Андрей Олейников ➠  CoreHard Autumn 2019
Как помочь и как помешать компилятору. Андрей Олейников ➠ CoreHard Autumn 2019
 
Автоматизируй это. Кирилл Тихонов ➠ CoreHard Autumn 2019
Автоматизируй это. Кирилл Тихонов ➠  CoreHard Autumn 2019Автоматизируй это. Кирилл Тихонов ➠  CoreHard Autumn 2019
Автоматизируй это. Кирилл Тихонов ➠ CoreHard Autumn 2019
 

Recently uploaded

Generative Artificial Intelligence: How generative AI works.pdf
Generative Artificial Intelligence: How generative AI works.pdfGenerative Artificial Intelligence: How generative AI works.pdf
Generative Artificial Intelligence: How generative AI works.pdfIngrid Airi González
 
Emixa Mendix Meetup 11 April 2024 about Mendix Native development
Emixa Mendix Meetup 11 April 2024 about Mendix Native developmentEmixa Mendix Meetup 11 April 2024 about Mendix Native development
Emixa Mendix Meetup 11 April 2024 about Mendix Native developmentPim van der Noll
 
Decarbonising Buildings: Making a net-zero built environment a reality
Decarbonising Buildings: Making a net-zero built environment a realityDecarbonising Buildings: Making a net-zero built environment a reality
Decarbonising Buildings: Making a net-zero built environment a realityIES VE
 
Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...
Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...
Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...panagenda
 
So einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdfSo einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdfpanagenda
 
Bridging Between CAD & GIS: 6 Ways to Automate Your Data Integration
Bridging Between CAD & GIS:  6 Ways to Automate Your Data IntegrationBridging Between CAD & GIS:  6 Ways to Automate Your Data Integration
Bridging Between CAD & GIS: 6 Ways to Automate Your Data Integrationmarketing932765
 
Connecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdfConnecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdfNeo4j
 
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...Alkin Tezuysal
 
Assure Ecommerce and Retail Operations Uptime with ThousandEyes
Assure Ecommerce and Retail Operations Uptime with ThousandEyesAssure Ecommerce and Retail Operations Uptime with ThousandEyes
Assure Ecommerce and Retail Operations Uptime with ThousandEyesThousandEyes
 
Email Marketing Automation for Bonterra Impact Management (fka Social Solutio...
Email Marketing Automation for Bonterra Impact Management (fka Social Solutio...Email Marketing Automation for Bonterra Impact Management (fka Social Solutio...
Email Marketing Automation for Bonterra Impact Management (fka Social Solutio...Jeffrey Haguewood
 
4. Cobus Valentine- Cybersecurity Threats and Solutions for the Public Sector
4. Cobus Valentine- Cybersecurity Threats and Solutions for the Public Sector4. Cobus Valentine- Cybersecurity Threats and Solutions for the Public Sector
4. Cobus Valentine- Cybersecurity Threats and Solutions for the Public Sectoritnewsafrica
 
Landscape Catalogue 2024 Australia-1.pdf
Landscape Catalogue 2024 Australia-1.pdfLandscape Catalogue 2024 Australia-1.pdf
Landscape Catalogue 2024 Australia-1.pdfAarwolf Industries LLC
 
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24Mark Goldstein
 
Generative AI - Gitex v1Generative AI - Gitex v1.pptx
Generative AI - Gitex v1Generative AI - Gitex v1.pptxGenerative AI - Gitex v1Generative AI - Gitex v1.pptx
Generative AI - Gitex v1Generative AI - Gitex v1.pptxfnnc6jmgwh
 
MuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotes
MuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotesMuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotes
MuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotesManik S Magar
 
Glenn Lazarus- Why Your Observability Strategy Needs Security Observability
Glenn Lazarus- Why Your Observability Strategy Needs Security ObservabilityGlenn Lazarus- Why Your Observability Strategy Needs Security Observability
Glenn Lazarus- Why Your Observability Strategy Needs Security Observabilityitnewsafrica
 
React JS; all concepts. Contains React Features, JSX, functional & Class comp...
React JS; all concepts. Contains React Features, JSX, functional & Class comp...React JS; all concepts. Contains React Features, JSX, functional & Class comp...
React JS; all concepts. Contains React Features, JSX, functional & Class comp...Karmanjay Verma
 
Accelerating Enterprise Software Engineering with Platformless
Accelerating Enterprise Software Engineering with PlatformlessAccelerating Enterprise Software Engineering with Platformless
Accelerating Enterprise Software Engineering with PlatformlessWSO2
 
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...Wes McKinney
 
A Glance At The Java Performance Toolbox
A Glance At The Java Performance ToolboxA Glance At The Java Performance Toolbox
A Glance At The Java Performance ToolboxAna-Maria Mihalceanu
 

Recently uploaded (20)

Generative Artificial Intelligence: How generative AI works.pdf
Generative Artificial Intelligence: How generative AI works.pdfGenerative Artificial Intelligence: How generative AI works.pdf
Generative Artificial Intelligence: How generative AI works.pdf
 
Emixa Mendix Meetup 11 April 2024 about Mendix Native development
Emixa Mendix Meetup 11 April 2024 about Mendix Native developmentEmixa Mendix Meetup 11 April 2024 about Mendix Native development
Emixa Mendix Meetup 11 April 2024 about Mendix Native development
 
Decarbonising Buildings: Making a net-zero built environment a reality
Decarbonising Buildings: Making a net-zero built environment a realityDecarbonising Buildings: Making a net-zero built environment a reality
Decarbonising Buildings: Making a net-zero built environment a reality
 
Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...
Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...
Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...
 
So einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdfSo einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdf
 
Bridging Between CAD & GIS: 6 Ways to Automate Your Data Integration
Bridging Between CAD & GIS:  6 Ways to Automate Your Data IntegrationBridging Between CAD & GIS:  6 Ways to Automate Your Data Integration
Bridging Between CAD & GIS: 6 Ways to Automate Your Data Integration
 
Connecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdfConnecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdf
 
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
 
Assure Ecommerce and Retail Operations Uptime with ThousandEyes
Assure Ecommerce and Retail Operations Uptime with ThousandEyesAssure Ecommerce and Retail Operations Uptime with ThousandEyes
Assure Ecommerce and Retail Operations Uptime with ThousandEyes
 
Email Marketing Automation for Bonterra Impact Management (fka Social Solutio...
Email Marketing Automation for Bonterra Impact Management (fka Social Solutio...Email Marketing Automation for Bonterra Impact Management (fka Social Solutio...
Email Marketing Automation for Bonterra Impact Management (fka Social Solutio...
 
4. Cobus Valentine- Cybersecurity Threats and Solutions for the Public Sector
4. Cobus Valentine- Cybersecurity Threats and Solutions for the Public Sector4. Cobus Valentine- Cybersecurity Threats and Solutions for the Public Sector
4. Cobus Valentine- Cybersecurity Threats and Solutions for the Public Sector
 
Landscape Catalogue 2024 Australia-1.pdf
Landscape Catalogue 2024 Australia-1.pdfLandscape Catalogue 2024 Australia-1.pdf
Landscape Catalogue 2024 Australia-1.pdf
 
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
 
Generative AI - Gitex v1Generative AI - Gitex v1.pptx
Generative AI - Gitex v1Generative AI - Gitex v1.pptxGenerative AI - Gitex v1Generative AI - Gitex v1.pptx
Generative AI - Gitex v1Generative AI - Gitex v1.pptx
 
MuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotes
MuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotesMuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotes
MuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotes
 
Glenn Lazarus- Why Your Observability Strategy Needs Security Observability
Glenn Lazarus- Why Your Observability Strategy Needs Security ObservabilityGlenn Lazarus- Why Your Observability Strategy Needs Security Observability
Glenn Lazarus- Why Your Observability Strategy Needs Security Observability
 
React JS; all concepts. Contains React Features, JSX, functional & Class comp...
React JS; all concepts. Contains React Features, JSX, functional & Class comp...React JS; all concepts. Contains React Features, JSX, functional & Class comp...
React JS; all concepts. Contains React Features, JSX, functional & Class comp...
 
Accelerating Enterprise Software Engineering with Platformless
Accelerating Enterprise Software Engineering with PlatformlessAccelerating Enterprise Software Engineering with Platformless
Accelerating Enterprise Software Engineering with Platformless
 
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
 
A Glance At The Java Performance Toolbox
A Glance At The Java Performance ToolboxA Glance At The Java Performance Toolbox
A Glance At The Java Performance Toolbox
 

C++20: The small things - CoreHard Autumn Conference

  • 1. Timur Doumler CoreHard Autumn Conference 30 November 2019 C++20: The small things @timur_audio Version 1.4
  • 2.
  • 3.
  • 4.
  • 6.
  • 7.
  • 8.
  • 9.
  • 10.
  • 11. 11 1 Initialisation 2 Structured bindings 3 Lambdas 4 Templates 5 constexpr 6 Miscellaneous
  • 12. 12 1 Initialisation 2 Structured bindings 3 Lambdas 4 Templates 5 constexpr 6 Miscellaneous
  • 13. Aggregates 13 struct Widget { int a; bool b; int c; };
  • 14. Aggregates 14 struct Widget { int a; bool b; int c; }; int main() { Widget widget = {3, true}; }
  • 15. Designated initialisers 15 struct Widget { int a; bool b; int c; }; int main() { Widget widget{.a = 3, .c = 7}; }
  • 16. 16 struct Widget { int a; bool b; int c; }; int main() { Widget widget{.a = 3, .c = 7}; } Only for aggregate types. C compatibility feature. Works like in C99, except: • not out-of-order Widget widget{.c = 7, .a = 3} // Error • not nested Widget widget{.c.e = 7} // Error • not mixed with regular initialisers Widget widget{.a = 3, 7} // Error • not with arrays int arr[3]{.[1] = 7} // Error Designated initialisers
  • 17. 17
  • 18. 18 Aggregates can no longer declare constructors
  • 19. 19 struct Widget { Widget() = delete; }; Widget w1; // Error Aggregates can no longer declare constructors
  • 20. 20 struct Widget { Widget() = delete; }; Widget w1; // Error Widget w2{}; // OK in C++17! Aggregates can no longer declare constructors
  • 21. 21 struct Widget { Widget() = delete; }; Widget w1; // Error Widget w2{}; // OK in C++17! Will be error in C++20 Aggregates can no longer declare constructors
  • 22. • Does not work with macros: 22 assert(Widget(2, 3)); // OK C++17 problems with aggregate initialisation:
  • 23. • Does not work with macros: 23 assert(Widget(2, 3)); // OK assert(Widget{2, 3}); // Error: this breaks the preprocessor :( C++17 problems with aggregate initialisation:
  • 24. • Does not work with macros: • Can’t do perfect forwarding in templates • can’t write emplace or make_unique that works for aggregates :( 24 assert(Widget(2, 3)); // OK assert(Widget{2, 3}); // Error: this breaks the preprocessor :( C++17 problems with aggregate initialisation:
  • 25. 25 struct Widget { int i; int j; }; Widget widget(1, 2); // will work in C++20! C++20: Direct-initialisation of aggregates
  • 26. 26 struct Widget { int i; int j; }; Widget widget(1, 2); // will work in C++20! int arr[3](0, 1, 2); // will work in C++20! C++20: Direct-initialisation of aggregates
  • 27. 27 struct Widget { int i; int j; }; Widget widget(1, 2); // will work in C++20! int arr[3](0, 1, 2); // will work in C++20! So in C++20, (args) and {args} will do the same thing! Except: • () does not call std::initializer_list constructors • {} does not allow narrowing conversions C++20: Direct-initialisation of aggregates
  • 28. 28 struct Colour { Colour(int r, int g, int b) noexcept; }; constinit
  • 29. 29 struct Colour { Colour(int r, int g, int b) noexcept; }; namespace Colours { const Colour red = {255, 0, 0}; } constinit
  • 30. 30 struct Colour { Colour(int r, int g, int b) noexcept; }; namespace Colours { const Colour red = {255, 0, 0}; // dynamic initialisation } constinit
  • 31. 31 struct Colour { Colour(int r, int g, int b) noexcept; }; namespace Colours { const Colour red = {255, 0, 0}; // dynamic initialisation } // -> initialisation order fiasco -> UB :( constinit
  • 32. 32 struct Colour { constexpr Colour(int r, int g, int b) noexcept; }; namespace Colours { constexpr Colour red = {255, 0, 0}; } constinit
  • 33. 33 struct Colour { constexpr Colour(int r, int g, int b) noexcept; }; namespace Colours { constexpr Colour red = {255, 0, 0}; // constant initialisation :) } constinit
  • 34. struct Colour { constexpr Colour(int r, int g, int b) noexcept; }; namespace Colours { Colour backgroundColour = getBackgroundColour(); } 34 constinit
  • 35. struct Colour { constexpr Colour(int r, int g, int b) noexcept; }; namespace Colours { Colour backgroundColour = getBackgroundColour(); // const or dynamic init? } 35 constinit
  • 36. struct Colour { constexpr Colour(int r, int g, int b) noexcept; }; namespace Colours { constinit Colour backgroundColour = getBackgroundColour(); } 36 constinit
  • 37. 37 constinit struct Colour { constexpr Colour(int r, int g, int b) noexcept; }; namespace Colours { constinit Colour backgroundColour = getBackgroundColour(); } // ^^^^^^ only compiles if init happens at compile time :)
  • 38. Database getDatabase(); for (auto&& user : getDatabase().getUsers()) { registerUser(user); } 38 Range-based for with initialiser C++17
  • 39. Database getDatabase(); for (auto&& user : getDatabase().getUsers()) // maybe undefined behaviour! { registerUser(user); } 39 Range-based for with initialiser C++17
  • 40. Database getDatabase(); auto db = getDatabase(); for (auto&& user : db.getUsers()) { registerUser(user); } 40 Range-based for with initialiser C++17
  • 41. Database getDatabase(); { auto db = getDatabase(); for (auto&& user : db.getUsers()) { registerUser(user); } } 41 Range-based for with initialiser C++17
  • 42. 42 Range-based for with initialiser Database getDatabase(); for (auto db = getDatabase(); auto&& user : db.getUsers()) { registerUser(user); } C++20
  • 43. 43 1 Initialisation 2 Structured bindings 3 Lambdas 4 Templates 5 constexpr 6 Miscellaneous
  • 44. 44 struct Widget { int i; bool b; }; auto [a, b] = getWidget();
  • 45. 45 struct Widget { int i; bool b; }; auto [a, b] = getWidget(); static [a, b] = getWidget(); // Error in C++17 thread_local [a, b] = getWidget(); // Error in C++17
  • 46. 46 struct Widget { int i; bool b; }; auto [a, b] = getWidget(); static [a, b] = getWidget(); // OK in C++20 thread_local [a, b] = getWidget(); // OK in C++20
  • 47. 47 struct Widget { int i; bool b; }; auto [a, b] = getWidget(); auto f = [a]{ return a > 0; }; // Error in C++17: // capture ‘a’ does not name a variable
  • 48. 48 struct Widget { int i; bool b; }; auto [a, b] = getWidget(); auto f = [a]{ return a > 0; }; // OK in C++20
  • 49. 49 struct Widget { int i; bool b; }; auto [a, b] = getWidget(); auto f = [a]{ return a > 0; }; // OK in C++20 // copies ‘a’, not the whole object
  • 50. 50 1 Initialisation 2 Structured bindings 3 Lambdas 4 Templates 5 constexpr 6 Miscellaneous
  • 51. template<class F, class... Args> auto delay_invoke(F f, Args... args) { return [f = std::move(f), ...args = std::move(args)]() -> decltype(auto) { return std::invoke(f, args...); }; } 51 C++20: pack expansion allowed in lambda init capture
  • 52. 52 – Lambdas are allowed in unevaluated contexts – Lambdas (without captures) are default-constructible and assignable More C++20 lambda features:
  • 53. 53 – Lambdas are allowed in unevaluated contexts – Lambdas (without captures) are default-constructible and assignable More C++20 lambda features: decltype([]{})
  • 54. 54 – Lambdas are allowed in unevaluated contexts – Lambdas (without captures) are default-constructible and assignable More C++20 lambda features: decltype([]{}) f;
  • 55. 55 – Lambdas are allowed in unevaluated contexts – Lambdas (without captures) are default-constructible and assignable More C++20 lambda features: class Widget { decltype([]{}) f; };
  • 56. 56 template <typename T> using MyPtr = std::unique_ptr< T, decltype([](T* t) { myDeleter(t); })>; MyPtr<Widget> ptr;
  • 57. 57 template <typename T> using MyPtr = std::unique_ptr< T, decltype([](T* t) { myDeleter(t); })>; MyPtr<Widget> ptr; using WidgetSet = std::set< Widget, decltype([](Widget& lhs, Widget& rhs) { return lhs.x < rhs.x; })>; WidgetSet widgets;
  • 58. 58 Generic lambdas / functions auto f = [](auto a){ return a * a; };
  • 59. 59 auto f = [](auto a){ return a * a; }; auto f(auto a) { // Generic *functions* – OK since C++20 :) return a * a; } Generic lambdas / functions
  • 60. 60 template <typename T> void f(std::vector<T> vector) { // ... } Generic lambdas / functions
  • 61. 61 template <typename T> void f(std::vector<T> vector) { // ... } // C++20: auto f = []<typename T>(std::vector<T> vector) { // ... }; Generic lambdas / functions
  • 62. 62 1 Initialisation 2 Structured bindings 3 Lambdas 4 Templates 5 constexpr 6 Miscellaneous
  • 64. 64 Non-type template parameters (NTTPs) template <int size> struct Widget { std::array<int, size> a; };
  • 65. 65 Non-type template parameters (NTTPs) template <int size> struct Widget { std::array<int, size> a; };
  • 66. 66 C++20: floating-point NTTPs template <double x> struct Filter { std::array<double, 2> coefficients = {x, 0.5 * x * x}; // stuff... };
  • 67. 67 C++20: class-type NTTPs struct Coefficients { double x; double y; };
  • 68. 68 C++20: class-type NTTPs struct Coefficients { double x; double y; }; template <Coefficients coeffs> struct Filter { // stuff :) };
  • 69. 69 C++20: class-type NTTPs struct Coefficients { double x; double y; }; template <Coefficients coeffs> struct Filter { // stuff :) }; constexpr Filter<Coefficients{1, 0.125}> f;
  • 71. 71 CTAD std::vector v = {1, 2, 3}; // std::vector<int>
  • 72. 72 CTAD std::vector v = {1, 2, 3}; // std::vector<int> std::tuple t = {42, 0.5, true}; // std::tuple<int, double, bool>
  • 73. 73 CTAD std::vector v = {1, 2, 3}; // std::vector<int> std::tuple t = {42, 0.5, true}; // std::tuple<int, double, bool> std::scoped_lock lock(rtmutex); // std::scoped_lock<std::recursive_timed_mutex>
  • 74. 74 C++20 adds: – CTAD for aggregates – CTAD for alias templates
  • 75. 75 template <typename T, typename U> struct aggr_pair { T t; U u; }; aggr_pair p = {1, true}; // Error: no deduction candidate found C++17
  • 76. 76 template <typename T, typename U> struct aggr_pair { T t; U u; }; template <typename T, typename U> aggr_pair(T, U) -> aggr_pair<T, U>; aggr_pair p = {1, true}; // OK C++17
  • 77. 77 template <typename T, typename U> struct aggr_pair { T t; U u; }; template <typename T, typename U> aggr_pair(T, U) -> aggr_pair<T, U>; aggr_pair p = {1, true}; // OK C++17 C++20 template <typename T, typename U> struct aggr_pair { T t; U u; }; aggr_pair p = {1, true}; // OK
  • 78. 78 template<typename... Bases> struct overloaded : Bases... { using Bases::operator()...; }; C++17
  • 79. 79 template<typename... Bases> struct overloaded : Bases... { using Bases::operator()...; }; template<typename... Bases> overloaded(Bases...) -> overloaded<Bases...>; C++17
  • 80. 80 template<typename... Bases> struct overloaded : Bases... { using Bases::operator()...; }; template<typename... Bases> overloaded(Bases...) -> overloaded<Bases...>; overloaded printer = { [](auto arg) { std::cout << arg << ' '; }, [](double arg) { std::cout << std::fixed << arg << ' '; }, [](const char* arg) { std::cout << std::quoted(arg) << ' '; } }; C++17
  • 81. template<typename... Bases> struct overloaded : Bases... { using Bases::operator()...; }; template<typename... Bases> overloaded(Bases...) -> overloaded<Bases...>; overloaded printer = { [](auto arg) { std::cout << arg << ' '; }, [](double arg) { std::cout << std::fixed << arg << ' '; }, [](const char* arg) { std::cout << std::quoted(arg) << ' '; } }; int main() { printer("Hello, World!"); } 81 C++17
  • 82. 82 template<typename... Bases> struct overloaded : Bases... { using Bases::operator()...; }; template<typename... Bases> overloaded(Bases...) -> overloaded<Bases...>; overloaded printer = { [](auto arg) { std::cout << arg << ' '; }, [](double arg) { std::cout << std::fixed << arg << ' '; }, [](const char* arg) { std::cout << std::quoted(arg) << ' '; } }; int main() { printer("Hello, World!"); } C++17
  • 83. template<typename... Bases> struct overloaded : Bases... { using Bases::operator()...; }; overloaded printer = { [](auto arg) { std::cout << arg << ' '; }, [](double arg) { std::cout << std::fixed << arg << ' '; }, [](const char* arg) { std::cout << std::quoted(arg) << ' '; } }; int main() { printer("Hello, World!"); } 83 C++20
  • 84. 84 namespace pmr { template <class T> using vector = std::vector<T, std::pmr::polymorphic_allocator<T>>; } C++17 std::pmr::vector<int> v{1, 2, 3};
  • 85. 85 namespace pmr { template <class T> using vector = std::vector<T, std::pmr::polymorphic_allocator<T>>; } C++17 C++20 std::pmr::vector<int> v{1, 2, 3}; std::pmr::vector v{1, 2, 3};
  • 86. 86 1 Initialisation 2 Structured bindings 3 Lambdas 4 Templates 5 constexpr 6 Miscellaneous
  • 87. 87 In C++20, in a constexpr function you can: – have a try-block – have an unevaluated asm block – use a union – call virtual functions – dynamic_cast and typeid – new and delete
  • 88. 88 Daveed Vandevoorde “C++ Constants” C++Now 2019 keynote Louis Dionne "Compile-time programming and reflection in C++20 and beyond” CppCon 2018 talk
  • 89. 89 “running” code at compile time int square(int i) { return i * i; }
  • 90. 90 “running” code at compile time constexpr int square(int i) { return i * i; } square(3); // compile time square(x); // runtime
  • 91. consteval int square(int i) { return i * i; } square(3); // compile time square(x); // Error - x is not a compile-time constant! 91 “running” code at compile time
  • 92. 92 compile time or runtime? int square(int i) { return __magic_fast_square(i); // contains runtime magic } square(3); // runtime, fast magic square(x); // runtime, fast magic
  • 93. 93 compile time or runtime? constexpr int square(int i) { return i * i; } square(3); // compile time square(x); // runtime, no fast magic :(
  • 94. 94 compile time or runtime? constexpr int square(int i) { if (std::is_constant_evaluated()) { return i * i; } else { return __magic_fast_square(i); } } square(3); // compile time square(x); // runtime, fast magic :)
  • 95. constexpr int square(int i) { if (std::is_constant_evaluated()) { return i * i; } else { return __magic_fast_square(i); } } square(3); // compile time square(x); // runtime, fast magic :) 95 compile time or runtime?
  • 96. 96 1 Initialisation 2 Structured bindings 3 Lambdas 4 Templates 5 constexpr 6 Miscellaneous
  • 97. 97 template <typename Container> auto findFirstValid(const Container& c) -> Container::iterator { return std::find_if(c.begin(), c.end(), [](auto elem){ return elem.is_valid(); }); }
  • 98. 98 template <typename Container> auto findFirstValid(const Container& c) -> Container::const_iterator { return std::find_if(c.begin(), c.end(), [](auto elem){ return elem.is_valid(); }); } // Error: missing 'typename' prior to dependent type name ‘Container::const_iterator'
  • 99. 99 template <typename Container> auto findFirstValid(const Container& c) -> Container::const_iterator { return std::find_if(c.begin(), c.end(), [](auto elem){ return elem.is_valid(); }); } // OK in C++20 :)
  • 101. 101 – [[likely]], [[unlikely]] New attributes in C++20
  • 102. 102 – [[likely]], [[unlikely]] – [[no_unique_address]] New attributes in C++20
  • 103. 103 – [[likely]], [[unlikely]] – [[no_unique_address]] – [[nodiscard]] on constructors New attributes in C++20
  • 104. 104 – [[likely]], [[unlikely]] – [[no_unique_address]] – [[nodiscard]] on constructors – [[nodiscard(“can have a message”)]] New attributes in C++20
  • 105. enum class rgba_color_channel { red, green, blue, alpha }; 105 Using enum
  • 106. enum class rgba_color_channel { red, green, blue, alpha }; std::string_view to_string(rgba_color_channel channel) { switch (channel) { case rgba_color_channel::red: return "red"; case rgba_color_channel::green: return "green"; case rgba_color_channel::blue: return "blue"; case rgba_color_channel::alpha: return "alpha"; } } 106 Using enum
  • 107. 107 Using enum enum class rgba_color_channel { red, green, blue, alpha }; std::string_view to_string(rgba_color_channel channel) { switch (channel) { case rgba_color_channel::red: return "red"; case rgba_color_channel::green: return "green"; case rgba_color_channel::blue: return "blue"; case rgba_color_channel::alpha: return "alpha"; } }
  • 108. enum class rgba_color_channel { red, green, blue, alpha }; std::string_view to_string(rgba_color_channel channel) { switch (channel) { using enum rgba_color_channel; case red: return "red"; case green: return "green"; case blue: return "blue"; case alpha: return "alpha"; } } 108 Using enum
  • 109. enum class Suit { diamonds, hearts, spades, clubs }; class Card { using enum Suit; Suit suit = spades; }; 109 Using enum
  • 110. 110 Built-in UTF-8 char type int main() { const char* str = u8" 🦄 🌈"; // C++17... }
  • 111. 111 Built-in UTF-8 char type int main() { const char* str = u8" 🦄 🌈"; // compile error in C++20! }
  • 112. int main() { const char8_t* str = u8" 🦄 🌈"; } 112 Built-in UTF-8 char type
  • 114. Timur Doumler CoreHard Autumn Conference 30 November 2019 C++20: The small things @timur_audio Version 1.4