Unfortunately there are many different cases in templates, where type deduction is different, and the behaviour is often not what you'd expect. Scott Meyers has a great talk on this, called "Type deduction and why you care", and I really think it's worth knowing about that when using templates.
I really love your style, you can perceive the preparation and work you put in your videos. Is there any chance you will make a new version of asm tutorials/serie? The old makes me cringe too much to follow it(audio/video/*shame*length)
Why does the template exe size matter? Suppose I had to define an int Swap, a float and a double Swap, I'd have 3 Swaps which the compiler would have to compile. If I wrote a template, and used int, float and double, it would still have to compile 3 Swaps. But then, it'll only make new datatype compilations for every new datatype used, which the programmer would do if it were done the way of overloading functions. So why does the template generate a larger exe?
+Anubhab Haldar You're right, it makes very little difference. I think template code is actually slightly smaller than lots of overloaded functions! I just wanted to point out that the function is not free. The compiler writes it for us. Thanks for watching and asking a great question!
dude templates a so awful, awful to debug, slows compiler... C++ template syntax is horrible, with all sorts of notorious problems with angle brackets and typename and other issues..Modern languages are so poorly designed that they hinder you more than they help when you are trying to actually program at a high level if you care about what the results are at the low level, which I do.
This guys has such an Australian accent that a kangaroo jumped out from my screen.
+micosair Classic!
+micosair hahahaha I really like him :D
Dude, your videos are amazing. Please keep making more.
You are good man and your voice reminds me of Aragon of middle earth.... Thank you
Hahaha, possibly the best thing anybody ever said to me! Thanks for watching brus, have a good one :)
"This won't be on your exam" - if you only knew what our exams are like! xD Thanks, mate! Your videos are gold. :)
Very nice tutorial. One of the best teacher around :-)
Unfortunately there are many different cases in templates, where type deduction is different, and the behaviour is often not what you'd expect. Scott Meyers has a great talk on this, called "Type deduction and why you care", and I really think it's worth knowing about that when using templates.
I really love your style, you can perceive the preparation and work you put in your videos. Is there any chance you will make a new version of asm tutorials/serie? The old makes me cringe too much to follow it(audio/video/*shame*length)
Why does the template exe size matter?
Suppose I had to define an int Swap, a float and a double Swap, I'd have 3 Swaps which the compiler would have to compile.
If I wrote a template, and used int, float and double, it would still have to compile 3 Swaps.
But then, it'll only make new datatype compilations for every new datatype used, which the programmer would do if it were done the way of overloading functions.
So why does the template generate a larger exe?
+Anubhab Haldar You're right, it makes very little difference. I think template code is actually slightly smaller than lots of overloaded functions!
I just wanted to point out that the function is not free. The compiler writes it for us.
Thanks for watching and asking a great question!
Great video, thanks.
Hey whats a creel im aussie and im a big fan!
+epic_kitty_lover489 Cheers kitty!
Sorry, I cannot find the function _Is_numeric in the head file , is it due to the update of the library?
Would have been cool to see some varidic templates.
very helpful.
You make me laugh with your comments!! :DDD
Codephile Dundee! :D
Hahaha, nice!
It's almost like a macro(?)
So this is the same as Java generics
I believe Java generics were implemented 10-15 years after C++ templates
dude templates a so awful, awful to debug, slows compiler... C++ template syntax is horrible, with all sorts of notorious problems with angle brackets and typename and other issues..Modern languages are so poorly designed that they hinder you more than they help when you are trying to actually program at a high level if you care about what the results are at the low level, which I do.