11 #ifndef TLX_ALGORITHM_MERGE_COMBINE_HEADER 12 #define TLX_ALGORITHM_MERGE_COMBINE_HEADER 32 template <
typename InputIterator1,
typename InputIterator2,
33 typename OutputIterator,
35 typename Combine = std::plus<
36 typename std::iterator_traits<InputIterator1>::value_type> >
38 InputIterator1 first1, InputIterator1 last1,
39 InputIterator2 first2, InputIterator2 last2,
40 OutputIterator result, Comparator cmp = Comparator(),
41 Combine combine = Combine()) {
47 return std::copy(first2, last2, result);
49 return std::copy(first1, last1, result);
52 if (cmp(*first1, *first2) < 0) {
56 else if (cmp(*first1, *first2) > 0) {
61 *result = combine(*first1, *first2);
72 #endif // !TLX_ALGORITHM_MERGE_COMBINE_HEADER OutputIterator merge_combine(InputIterator1 first1, InputIterator1 last1, InputIterator2 first2, InputIterator2 last2, OutputIterator result, Comparator cmp=Comparator(), Combine combine=Combine())
Merge two sorted ranges and add all items comparing equal.