C++Now 2016 has ended
Please visit the C++Now website.
Back To Schedule
Thursday, May 12 • 9:00am - 10:30am
Variadic expansion in examples

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

Templates - and variadic templates - are an important aspect of writing a successful library in C++; libraries that can deal with custom types the user creates greatly eases their use. Variadic templates specifically are still a new, relatively unknown and at the same time quite a buggy (in the sense of bugs in their implementations) tool, but nevertheless, they offer much easier ways of creating truly generic types and functions. This talk will focus slightly less on variadic templates in general; the common pitfalls will be discussed, but more attention will be given to the tool of parameter pack expansion and all the contexts where it can be used, especially as a code generation tool. The talk will start mostly from scratch, assuming the audience's general knowledge about templates. It'll introduce the idea of variadic templates and general syntax and typical techniques for their use. Next, it will head into the (mostly) unknown and buggy lands of the interesting uses of variadic packs, like unpacking a tuple into a function call using `std::integer_sequence`, the use of empty packs for a slightly easier way to work with `enable_if`. The final examples will explain the way of invoking an expression per every argument in a pack, and dispatch to appropriate version of code for each of the argument types based on runtime values, which will be used to more easily create variant visitors.

avatar for Michał Dominiak

Michał Dominiak

System Software Engineer, Nvidia

Thursday May 12, 2016 9:00am - 10:30am MDT
Flug Auditorium