| 307 | |
| 308 | template <typename OutputContainer, typename Function, typename Container1, typename Container2> |
| 309 | OutputContainer zipWith(Function&& function, Container1 const& cont1, Container2 const& cont2) { |
| 310 | auto it1 = cont1.begin(); |
| 311 | auto it2 = cont2.begin(); |
| 312 | |
| 313 | OutputContainer out; |
| 314 | while (it1 != cont1.end() && it2 != cont2.end()) { |
| 315 | out.insert(out.end(), function(*it1, *it2)); |
| 316 | ++it1; |
| 317 | ++it2; |
| 318 | } |
| 319 | |
| 320 | return out; |
| 321 | } |
| 322 | |
| 323 | // Moves the given value and into an rvalue. Works whether or not the type has |
| 324 | // a valid move constructor or not. Always leaves the given value in its |