CppCon 2016: Arthur O'Dwyer “Template Normal Programming (part 2 of 2)'

preview_player
Показать описание


What is "template normal programming"? It's template metaprogramming without so much of the "meta" part! During this talk, I promise not to mention SFINAE, or recursion, or standard type traits. We'll focus on the common scenarios "I think this code could benefit from templates, but I don't understand how to organize it;" "I can't get anything to compile without errors;" and "My coworker wrote some template code and I don't understand any of it."

In Part I of the talk, we'll start with function templates and class templates, then explain variable templates (new in C++14) and template aliases (new in C++11). We'll do a deep dive into template type deduction; then talk about full and partial specialization; and finish up with an example that motivates the final feature of C++11 template syntax, explicit instantiation.

In Part II of the talk, we'll begin by demystifying tag dispatch and traits classes; discuss situations in which you have to add disambiguating "template" or "typename" keywords (and why); and do a deep dive into the rules of what gets instantiated when and where. We'll revisit template type deduction just long enough to explain how it works for variadic templates; and explain two common template idioms — the Curiously Recurring Template Pattern and the Mixin Pattern.
Time permitting, we'll finish by exploring the big new features of templates according to the C++17 Draft Standard:
- template
- type deduction for class template constructors
- explicit deduction guides

Arthur O'Dwyer
Software Engineer, Mixpanel
Arthur O'Dwyer worked for many years at Green Hills Software, making the world's most optimizing C and C++ compilers. Now he works at Mixpanel in San Francisco, where he organizes a monthly C++ meetup.


*-----*
*-----*
Рекомендации по теме
Комментарии
Автор

Need to watch this at least 3 times before it sinks in !

utki
Автор

The first time I listened to it, I fell asleep 😂 let's go for the next step

mohammadsadeghzadeh
Автор

14m:33s Arthur says function templates can't be partially specialized, but it appears what he is demonstrating here is actually function overloading. (Not that this takes away from the following implementation: tag dispatch is the right solution here.)

Skeksis
Автор

very useful presentation and a lot of useful techniques.

perfumedsea
Автор

Real useful stuff. Thank you very much.

vladislavkaplan
Автор

Well structured presentation, one step at a time. However, especially the second part is a little rushed through, which makes it hard to follow.

pleiadiblu
Автор

Good stuff, but showing the difference of template instantiation and initialization was horrifically confusing.

tombranson
Автор

Too complicated to be useful. Imagine how much time we need to code review and debug. Subtle differences can cause dramatic changes. Still this is a very helpful and informative talk. Most C++ books just includes a very brief intro to template programming, as if it is so easy to use. In fact it’s not.

thedzu
Автор

can't get this exaplest to work with clang3.9 ;]

lukasz
Автор

You need to book more time dude! Good stuff though.

MrSapps
Автор

Damn. I was looking for Scott Meyers or this guy to talk about CRTP and he just skipped the pattern...

xealit
Автор

Dont say "call it" when all the phones in the room are listening you.. I wonder who had "it" in the contacts?

andreaspokorny
Автор

Templates still look like black magic to me :/.

Forritouno