concept filter in category c++

appears as: filter, filter
Functional Programming in C++

This is an excerpt from Manning's book Functional Programming in C++.

The filter construct takes a collection and a predicate function (T → bool) as arguments, and it returns a collection of filtered items, so its type is written like this:

Listing 2.15 Calling the helper function
template <typename FilterFunction, typename Iterator>
std::vector<std::string> names_for(
        Iterator people_begin,
        Iterator people_end,
        FilterFunction filter)
{
    return names_for_helper(people_begin,
                            people_end,
                            filter,
                            {});
}

Figure 7.1 The view created by filter stores an iterator to the source collection. The iterator points to only the elements that satisfy the filtering predicate. The user of this view will be able to use it as if it were a normal collection of people with only three elements in it: Martha, Jane, and Rose.

c07_01.png