Template Metaprogramming: Practical Application - Jody Hagins - CppCon 2021

preview_player
Показать описание
---
This presentation is a tutorial covering multiple metaprogramming topics. It builds upon last year's "Template Metaprogramming: Type Traits." That talk walked you through template metaprogramming fundamentals by implementing some basic type traits. This tutorial demonstrates how to build upon these basic building blocks to solve real world problems.

For example, we will explore how to manage types as plain lists and associative collections. However, we will not just demonstrate how to sort a collection of types, but also some practical use cases where such techniques provide significant advantages, both in representation and runtime performance.

We will look some explicit real world examples where we trade an upfront compile time cost for faster runtime performance. We will also explore ways to measure the compile time costs so that we can make educated decisions about how to improve the compile time performance, and determine if that cost is worth the runtime gain.

Thus, the tutorial will walk through a number of metaprogramming techniques and tricks, but with the goal of applying them to solve several explicit real world problems, all the while being very aware of the compile time costs.

---
Jody Hagins

Jody Hagins first compiled "C++" code in 1984, and wrote a specialized LisP editor using Zortech C++ for senior project in 1988. However, he didn't truly start programming in C++ until 1992, when he read The Greatest C++ Book Ever Written, "Advanced C++ Programming Styles and Idioms" by Jim Coplien. That book, combined with cfront, which generated C code from C++ source, gave him the joyful task of writing SVr4 Streams drivers in C++. Ever since, he has been hooked on writing C++ code for kernel modules, large telephony applications, and, since the late 1990s, applications in what is now known as the high frequency trading industry.

---

The CppCon YouTube Channel Is Sponsored By:
Рекомендации по теме
Комментарии
Автор

Books mentioned in the talk. "Advanced C++ Programming Styles and Idioms' by James O. Coplien. "C++ Template Metaprogramming: Concepts, Tools, and Techniques from Boost and Beyond" by David Abrahams, Aleksey Gurtovoy, "Modern C++ Design: Generic Programming and Design Patterns Applied" by Andrei Alexandrescu.

zhaoli
Автор

The feeling when you think you know c++ and then you see a video like this...

tomaskot
Автор

such high-class content is available for free. Hats off cppcon

ajainitbhu
Автор

Void_t is so useful. If not watch your talk, Jody, My project world be postponed. So grateful.

yuehuajia
Автор

How type_id() can look? I can implement it using the typeid() operator but in this case TypeId should contains a string_view as a value or a pointer to const char and create a temporary string_view in the operator< definition.

UPD: I thought I can, but std::type_info::name() is not a constexpr function and cannot be used in a constant expression.

samolisov
Автор

38:00. I don't see the purpose of this "Compile Times" table.The rows "recursive" and "linear array" are NOT doing the same thing. Why put it in the same table and compare them? To confuse audience/viewers?

sirnawaz
Автор

Does C++ template metaprogramming reducing complexity or increasing it?

ravishankars
Автор

I can almost hear Sean Baxter jeering in the background how much easier this is in circle c++

nathanfranck
Автор

So why Void_t works when std::void_t not?

vanyakhodor
Автор

From 2011 to now i see that C++ going on wrong way. We need more mathematician who don’t know CS.

__hannibaalbarca__
Автор

somwhat is it for ‘its awesome.. its super.. its …. ‘ …. hmm so basically you are so exited that you cant answer your own question….

Alperic
Автор

This is crazy. I am living off programming since 1996 and I have so far didn't find any practical benefits in using CPP templates. The unreadable and inconsequential mess presented here just confirms my experience.

Martinko_Pcik