Leave these fields empty (spam trap):
Name
You can leave this blank to post anonymously, or you can create a Tripcode by using the format Name#Password
Comment
[i]Italic Text[/i]
[b]Bold Text[/b]
[spoiler]Spoiler Text[/spoiler]
>Highlight/Quote Text
[pre]Preformatted & Monospace Text[/pre]
[super]Superset Text[/super]
[sub]Subset Text[/sub]
1. Numbered lists become ordered lists
* Bulleted lists become unordered lists
File

Sandwich


Discord Now Fully Linked With 420chan IRC

C++ Templates beyound trivial stuff

Reply
- Sat, 02 Dec 2017 15:40:10 EST 9QSfnS0r No.37248
File: 1512247210926.jpg -(155896B / 152.24KB, 977x1488) Thumbnail displayed, click image for full size. C++ Templates beyound trivial stuff
What's the deal with C++ templates?
I'm looking for explanatory videos on it that is reasonably well produced
(not some enthusiastic dude rambling to a screen recording)

Doesn't have to be a video though if it's well written. All explanations I've found so far don't give me any reason of why to use them at all (instead for instance method overloading)

Some time I'd need to for instance loads of static data that I could define by hand but still would like to take advantage of encapsulating things that resemble state machines in classes.
I use C++ for microcontrollers, never on a PC and some times access to hardware can't be done inside a class the straight forward way, like storing pointers to a hardware pin, timer register, etc... inside anything non-static.
>>
Nicholas Banningpat - Sat, 02 Dec 2017 19:30:43 EST v79vrqu4 No.37249 Reply
Templates are about generics and generics are about types. You should understand the type system and how generics work if you want to call yourself a C++ programmer, but that's not to say your embedded code will suffer if you don't.
>>
Nathaniel Clublingson - Sat, 02 Dec 2017 20:00:31 EST BW3MomrQ No.37250 Reply
For embedded code, you probably don't need templates for much. Maybe if you have 8, 16, and 32-bit data types you could write code that could use any of those interchangeably, but I don't think it'd be as useful for you as for someone writing for more flexible systems.
>>
Graham Gublingwidge - Wed, 21 Mar 2018 05:04:05 EST 22oSMVrj No.37481 Reply
>>37248
You can do a lot more with templates than just generic types like some noobs would say. There is a famous book on templates called C++ Templates: The Complete Guide. You can find the first edition easily and I have also found the second edition online for free but it seems to have been taken down by now.
>>
Basil Smallwell - Thu, 26 Jul 2018 02:13:08 EST Xm/W+3lL No.37596 Reply
>>37595
I think you might be in the wrong forum?

Report Post
Reason
Note
Please be descriptive with report notes,
this helps staff resolve issues quicker.