Understanding the constrained algorithms
The standard library provides over one hundred general-purpose algorithms. As we discussed in the introductory section for the ranges library earlier, these have one thing in common: they work with abstract ranges with the help of iterators. They take iterators as arguments and they sometimes return iterators. That makes it cumbersome to repeatedly use with standard containers or arrays. Here is an example:
auto l_odd = [](int const n) {return n % 2 == 1; }; std::vector<int> v{ 1, 1, 2, 3, 5, 8, 13 }; std::vector<int> o; auto e1 = std::copy_if(v.begin(), v.end(), std::back_inserter(o), l_odd); int arr[] = { 1, 1, 2, 3, 5, 8, 13 }; auto e2 = std::copy_if(std...