Learn what a type inference is and how it impacts your templates. Also, learn how to infer a derived return type of a template function.
- [Instructor] In previous versions of C and C++,…the auto keyword declared a variable in automatic storage…and this was the default storage within a block anyway.…So the keyword was rarely if ever used.…So beginning with C++11, the auto keyword…has been repurposed to provide type inference.…Here I have a working copy of auto.cpp from Chapter 1…of the Exercise Files, and we have a number…of variable definitions here beginning on Line 9.…
And you'll note that later on here…I'm using typeid to get the internal names of the types.…These names are implementation dependent.…So if you're following along on a PC…or another platform, these names will be different.…When I build and run this, you see it displays the names,…and it says things like PKc for a c-string…and i for an integer and this long thing…for the STL string class which is defined here, sclass.…
So these names will be different on different platforms…just so that you're aware of that.…You'll notice here on Line 13…I define a variable called x based on a c-string.…
- 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.