Learn how the STL logical functors provide Boolean logical operators for transform and other functions that require operator functions.
- [Instructor] The logical operator functors,…or standard template functors,…defined in the functional header of the STL.…And there's the functional header there.…Here I have a working copy of logical.cpp…from chapter five of the exercise files.…The transformation function down here is the binary version,…and I have three vectors of ints.…And of course these can be any logical, compatible type,…so any scaler value.…
They could just easily be bool.…If we build and run this,…you see that the results are in ones and zeroes.…If I change all these to bool, it works exactly the same.…And build and run.…The logical and does what you'd expect it to do.…In each of the positions…where both of these values are true,…the result will be true.…The logical or.…
We'll run that.…That is true where you have a one in either place.…And the logical not is actually a unary function.…So I can take this out…and when I build and run,…it gives you the inverse of our V1 vector.…These logical operators are often useful…for simple transformations and other applications…
- 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.