We can accomplish a lot of things with transform, accumulate, and any_of/all_of/none_of. Sometimes, however, we need to filter out some of the data from collections.
The usual style of doing this is with find_if. However, find_if is cumbersome if what we need is to find all the items from a collection that fit a specific condition. Therefore, the best option to solve this problem in a functional way using the C++ 17 standard is copy_if. The following example uses copy_if to find all the minors in a list of people:
TEST_CASE("Find all minors"){
vector<Person> people = {
Person("Alex", 42),
Person("John", 21),
Person("Jane", 14),
Person("Diana", 9)
};
vector<Person> expectedMinors{Person("Jane", 14),
...