Learn how the compiler generates code for the template, what specialization is, how this effects compile time and runtime.
- [Lecturer] When you invoke a template with a specific type…the compiler creates a specialization for the template…with that specific type.…Let's take a look at how this works,…here I have a working copy of template function .CPP…from chapter one of the exercise files.…When I call the template function on line sixteen…the compiler creates a specialization,…this happens at compile time.…The specialization is effectively a copy of the function,…specifically for a given set of types.…
The specialization is invisible to the programmer,…this happens at compile time entirely behind the scenes.…So in the case of our example,…it's as if a function were created like this…with Int Maxof const Int A,…and const Int & B return…and the rest…of this is just exactly like that.…(typing)…So if I were to run this function several times once…with type say short Int and once with type long Int,…It would create three separate specializations…of this function one with type short Int…and one with type long Int…Specializations are both the blessing…
- Template fundamentals
- STL containers
- Accessing iterators
- Output, forward, and bidirectional iterators
- The transform function
- Transforming strings and types
- Arithmetic, relational, and logical functions
- STL algorithms
Skill Level Intermediate
2. STL Containers
3. STL Iterators
5. STL Functions
6. STL Algorithm
- Mark as unwatched
- Mark all as unwatched
Are you sure you want to mark all the videos in this course as unwatched?
This will not affect your course history, your reports, or your certificates of completion for this course.Cancel
Take notes with your new membership!
Type in the entry box, then click Enter to save your note.
1:30Press on any video thumbnail to jump immediately to the timecode shown.
Notes are saved with you account but can also be exported as plain text, MS Word, PDF, Google Doc, or Evernote.