Loading…
CppCon 2020 has ended
Back To Schedule
Tuesday, September 15 • 13:30 - 14:30
Back to Basics: Templates (part 2 of 2)

Log in to save this to your schedule, view media, leave feedback and see who's attending!

Feedback form is now closed.
Template Basics

This talk is a two-parter. In the first part we start with the question what is generic programming. I then will introduce the different kinds of templates: function, class and method templates. We will walk through how to write and apply. Along with that we distinguish the different types of template parameters type, and non-type using std::array as an illustration. This is accompanied by a peak behind the scenes by using C++ Insights. This should also give you a valuable tool where you can checkout details for yourself.

At this point we look at alias templates and how they can help us.

Once we covered the basics, we take care that our templates do not bloat the code. For that we use an example of passing an array and a length and optimize this. While on that, we consider at type_traits and incorporate them in our solution. With type_traits we use constexpr if for conditional compile-time code paths.

This session is for developers with C++ experience who have avoided templates so far. After attending this talk, attendees have learned to think in types rather than in values and can write their own templates.


-----


Advanced Templates

This is the second part of Templates where go more into depth. Attendees expected to know the syntax an properties of function and class templates, type_traits and constexpr if.

In this session, we look at variadic templates together with fold expressions by using a Printf like function as an example. This knowledge is then used to talk about template specializations.

At this point we will briefly talk about SFINAE. We compare it to the tag-dispatching pattern and see how C++20s Concepts make SFINAE way less scary. Next on the plate are variable templates as well as template template parameters.

This session is for developers with C++ experience who have avoided templates so far. After attending this talk, attendees have learned techniques like SFINAE and template specializations.

Speakers
avatar for Andreas Fertig

Andreas Fertig

Unique Code
Andreas Fertig is the CEO of Unique Code GmbH, which offers training and consulting for C++ specialized in embedded systems. He worked for Philips Medizin Systeme GmbH for ten years as a C++ software developer and architect focusing on embedded systems.Andreas is involved in the C... Read More →


Tuesday September 15, 2020 13:30 - 14:30 MDT
Back to Basics