In this workshop, we will take a look into how Python-style named tuples can be implemented in C++20.
The goal will be to test and implement the following snippet from scratch with modern C++ features.
01 const auto tuple = namedtuple{"price"_t = 42, "size"_t = 1'000};
02 static_assert(42 == tuple["price"_t]);
03 static_assert(1'000 == tuple["size"_t]);
04 static_assert(not [](auto tuple) { return requires { tuple["quantity"_t];}(tuple))
At the end of this session, the audience will have a better understanding of C++20 features such as:
- Concepts
- User-Defined Literals
- New additions to lambdas
- std::fixed_string
Additionally, attendees will get familiar with an expressive way of writing modern C++.
Let's get ready to named all tuples at CppCon 2021!
[1] https://docs.python.org/3/library/collections.html
ALL TALK SESSIONS CAN BE ACCESSED FROM THE MAIN LOBBY:
https://cppcon.digital-medium.co.uk/