Learn how the transform function is used to perform bulk transformations on the elements of a container, using a supplied operator function.
- [Narrator] The transform function…is used to run bulk transformations…on elements in a container.…Here I have a working copy of transform.cpp…from chapter four of the exercise files.…The transform template function…is found in the algorithm header…and we'll get back to these template class…and functions at the top here in a minute.…Take a look at the transform function itself.…This version of it takes four arguments.…
The first is a starting point iterator…and its input iterator…so it only needs to end forward.…The second is also an input iterator…for the endpoint of the source container.…So these first two are the begin point…and the endpoint of this first container,…and the third one is the begin point…of the destination container and it is of course…an output iterator.…The fourth argument is an object operator.…It's a unary function, so it's a pointer…to either a function or a object functor…that takes one argument.…
In this case it's pointing to X.…And you see that X is declared up here…as an object of the class accum,…
- 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.