cpprussia C++ Russia 2019 SPb (31.10.2019 — 01.11.2019)

Clauses, qualifiers and patterns

img

Declaring a variable or a function in C++ might be tricky. When should we make it static and inline? const and constexpr? What about consteval and constinit? How do templates affect this? In this talk, Mikhail will try to sort out all this variety of concepts.

In C++98 we had const, volatile, static, extern, inline and of course patterns. In C++11 thread_local, constexpr and also extern for patterns were added. In C++14 variables patterns were added. In C++17 — inline variables. In C++20 they promise to add consteval and constinit. Have you ever wondered what is static inline thread_local constexpr const volatile variable?

In this talk Mikhail will try to sort out all this variety of keywords. We will recall linkage, storage duration and patterns instantiation (and learn what will change with the dawn of modules in C++20). Examine connection between template and inline, static and constexpr. Understand why we need extern now when we have inline. And will realize how it took almost 20 years to learn how to declare constants.

The talk is designed for basic knowledge of C++.