Templates in C++

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


Thank you to the following Patreon supporters:
- Samuel Egger
- Dominic Pace
- Kevin Gregory Agwaze
- Sébastien Bervoets
- Tobias Humig
- Peter Siegmund

Gear I use:
-----------------

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

"By no means is this going to be the only video I make on templates"
- The Cherno 2017

AhmedTahagg
Автор

For all the novices out there, I think there's one important thing he overlooked regarding using templates. With templates, you must either write AND use them inside a SINGLE source (cpp) file, OR you must write them ENTIRELY inside a header file. Unlike a regular function or class, you can NOT declare them inside a header file and then define them inside a source file. The linker won't be able to link the templates if you do.

sigmareaver
Автор

I love this series. Motivated me to learn c++ and just got my first job as a software engineer. Keep it up!!!

baaryl
Автор

I know he’s an expert in C++ because he can talk about single concept for ~20 min, where every second counts 👍

HanhTangE
Автор

Simply, the best C++ lessons in existence.

VadimMelnicuk
Автор

Another reason you shouldn't want to go too crazy with templates is compilation times. As cherno said, you're basically having the compiler write code for you. If you start having your compiler write a ton of code for you, then be prepared to wait a bit longer for your program to compile.

bgzdevtips
Автор

Template = compile time polymorphism

I don't like overuse of template, debugging is a nightmare. I have seen this horror myself.

someone
Автор

Dude, your videos are incredibly well explained, never seen that in any other channel. As a junior C/C++ developer myself, I learn a lot of new things from you. Keep up the C++ series going!! Great job!

Kromush
Автор

As a matter of fact, the templates system is turing complete - that means you can actually implement ANY computer program using templates (and that program will run at compile time).
Great video !

GFXNever
Автор

The thing I loved back when I started with C++ and learnt about templates (although the syntax can understandably look like drunk talk to people) was the fact that this is NOT some dynamic thing based on some shared base object the entire language uses but still enables you to create equally or more flexible code. By having the compiler generate the needed code for each type you use your templates with you basically add no extra runtime cost. That was awesome to young me.

Another great side effect of how templates work and the fact that the template doesn't actually "exist as code" is that you can have a huge library of templates and it would not actually grow your binary a crazy amount unless you use them all. If it instead was a hughe library of "actual code" your binary would contain them all even if you only used a few of them.

DanielLiljeberg
Автор

Dude, please don't let this C++ series go for OpenGL, Hope to see them both continue. Keep up the great work!

ToxicityGameDev
Автор

C++23 made it easier. You can type:

void Func(auto var) {
std::cout << var << std::endl;
}

YScript
Автор

*My takeaways:*
1. Problem with function overloading 2:02
2. Function template 4:01
3. Class template (variable) 10:06
4. Class template (data type and variable) 12:16
5. Where we may use template 16:10

leixun
Автор

I was trying to understand this Templates for such long time, and only now i understand thank you very much !

raf.nogueira
Автор

Really appreciate your series.. The way you explain things is so simple and effective

ShivamSingh-ueqi
Автор

Clear, concise and straight to the point.

MoTharwat-swdc
Автор

Easily the best C++ resource on YouTube, thanks man!

mbwilding
Автор

I love your series! I was having trouble in my C++ class and my TA suggested I should watch your videos. It has helped immensely

koobyroory
Автор

You sir are amazing..we need more from you. Please do not stop making videos

namahshrestha
Автор

"This can get really crazy, really quickly" is my favourite quote here.

LeandroNunesLeandroN