C++ Weekly - Ep 4 Variadic Template Refactor

preview_player
Показать описание
☟☟ Awesome T-Shirts! Sponsors! Books! ☟☟

In this episode I go over some refactoring of non-variadic template code to make it into variadic templates. T-SHIRTS AVAILABLE!

WANT MORE JASON?

SUPPORT THE CHANNEL

GET INVOLVED

JASON'S BOOKS

► C++23 Best Practices

► C++ Best Practices

JASON'S PUZZLE BOOKS

► Object Lifetime Puzzlers Book 1

► Object Lifetime Puzzlers Book 2

► Object Lifetime Puzzlers Book 3

► Copy and Reference Puzzlers Book 1

► Copy and Reference Puzzlers Book 2

► Copy and Reference Puzzlers Book 3

► OpCode Puzzlers Book 1


RECOMMENDED BOOKS

AWESOME PROJECTS

O'Reilly VIDEOS

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

I am watching this with some "hindsight" - the std::initializer_list trick is horrible (to try to understand) - the sort of thing that would have put me off attempting such things before! But now I am using c++17 I think this can be done with fold expressions (please correct if wrong), although these are tricky to get your head around... Also the first method you tried (the recursive call) could be solved with "constexpr if" on the number of template args (again correct if wrong) - so these are just two ways that templates have come on so much so people like me can play too :)

alastair
Автор

is it possible to define them recursively though and specify the base case for empty template ?
i couldn't find the correct syntax for it

walidhanniche