From the course: C++ Templates and the STL

Unlock this course with a free trial

Join today to access over 22,600 courses taught by industry experts.

Relational functors

Relational functors

- [Instructor] The relational functors are standard template functors defined in the functional header of the STL, and here's the functional header there. I have a working copy of relational.cpp from chapter five of the exercise files. And I just wanted to show you this really quick, my normal display V for displaying vectors. I have modified it a little bit, because we're going to be talking about relational operators. If the type ID of the vector is bool, then I want to display true and false, rather than simply the value. And so here's a nice little use of type ID to check the type of a template type inside of a template and do something different if it's one type then another. This works really, really well and it's not that uncommon. So here we have three vectors. Two of them are of type long and they have these integer values in them, and this one is of type bool, which will be for our result. Here's our functor and this is from the functional header in the STL. And we're using…

Contents