C++ Weekly - Ep 6 Intro To Variadic Templates

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

In this episode Jason gives a brief introduction to variadic template programming. 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

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

nm has an option '-C' which automatically demangles the C++ names.

planetmuman
Автор

Excellent. I explored this feature about 12 months ago but was working with legacy code since so no chance to dive back in. The code;

return { to_string(param)... };

is the part that caught my eye. (param)... those dots! :) I'll continue on with this series, its exactly whats needed to get this stuff understood (for me anyways). Watching compile time, symbol table and exe size, glaringly obvious but not something I have observed. Its now in my box of tools! :)

Thank YOU!

grahamdd
Автор

c++17 one-liner without lambdas:

_template<typename ... Param>_
_const auto to_string(const Param& ... param)_
_{_
_return std::vector{ (std::stringstream() << param).str() ... }; // works in MSVC v14.2 (VS 2019 v16)_
_return std::vector{ << param).str() ... }; // works in gcc/clang/MSVC_
_}_

raducusmir
Автор

Year and a half late, I could go for a 2-4 point increase in editor font. Otherwise great stuff, concise, good explanation, and nice pace.
So many other videos either run through so fast your mind is occupied just attempting to unpack the words or they go off into the weeds and waste a bunch of time on trivial aspects often barely touching on the fundamental components.

mytech
Автор

Very useful, glad I stumbled upon this video

almighty
Автор

Something that seems overlooked in the standard is when using the 'using' keyword. You can't use the ... expansion operator on the variadic list when you want to expose for example a specific function which is available in all the types of the variadic template list.

chrisminnoy
Автор

Thanks for the great video. Did you know nm -C will demangle C++ for you?

weegreenblobbie
Автор

Thanks, very helpful, although it took me some additional reading on Stack Overflow to understand the recursion.

ksawery
Автор

Nice explanation, can you please post a session for factory design patterns in c++ ?

arpitmaiya
Автор

g++ 7.2 produces less executable size with generic lambda ...

dshvets
Автор

Possibly the creation of the different functor classes for the generic lambda resulted in the increased program size?

Blaqkmagic
Автор

Would it be possible to use any ide, so you can see your code errors right away instead of wasting so much time to switch between vim and terminal.

MrVermond
Автор

About the increase in size of exe when using generic lambdas, cud it be due to every function call having local copy of lambda object, what if we passed that lambda by reference to generic to_string.

surajkukreja
Автор

that was good, particularly not having a canned response before you started. I find variadics and fold expressions very confusing, much more difficult to understand than C's original vararg idiom. I haven't tried this myself yet, but how does the compiler manage to return a vector of strings without apparently doing any allocations or push_backs?

treyquattro
Автор

I just revisited this old video and your series was cool back then too. Doesn't your long template perform an unnecessary copy in each recursion?

adamhunyadi
Автор

very good example . though i have seen this earlier but again its still cool

karuneshmarch
Автор

Please, tell me, what is this font you're using in this terminal? Looks awesome! I couldn't find it by myself.

BloganProgramming
Автор

I can't believe that I wasted brain cells learning this shit early in my programming career.

jony
Автор

Very Good Video Lekin kuuch samjh nahi aya....

mustafakhozemadholkawala
Автор

I think newer version of nm or gcc lambdas are symbols

alexstone