35template <
typename ForwardIterator,
typename BinaryOp>
36void for_each_pair(ForwardIterator first, ForwardIterator last, BinaryOp op) {
37 while (first != last) {
38 auto next = std::next(first);
39 std::for_each(next, last, [&](
auto const &nth) { op(*first, nth); });
45template <
typename ForwardRange,
typename BinaryOp>
49 for_each_pair(begin(rng), end(rng), std::forward<BinaryOp>(op));
60template <
typename ForwardIterator,
typename BinaryOp>
62 ForwardIterator first2, ForwardIterator last2,
64 while (first1 != last1) {
65 std::for_each(first2, last2, [&](
auto const &nth) { op(*first1, nth); });
71template <
typename ForwardRange,
typename BinaryOp>
77 std::forward<BinaryOp>(op));
88template <
typename ForwardIterator,
typename BinaryOp,
typename BinaryCmp>
90 ForwardIterator first2, ForwardIterator last2,
91 BinaryOp op, BinaryCmp cmp) {
92 while (first1 != last1) {
93 std::for_each(first2, last2, [&](
auto const &nth) {
94 if (cmp(*first1, nth)) {
103template <
typename ForwardRange,
typename BinaryOp,
typename BinaryCmp>
105 BinaryOp &&op, BinaryCmp cmp) {
109 std::forward<BinaryOp>(op),
110 std::forward<BinaryCmp>(cmp));
void for_each_pair(ForwardIterator first, ForwardIterator last, BinaryOp op)
Execute op for each pair of elements in [first, last) once.
void for_each_cartesian_pair(ForwardIterator first1, ForwardIterator last1, ForwardIterator first2, ForwardIterator last2, BinaryOp op)
Execute op for each pair of elements between [first1, last1) and [first2, last2).
void for_each_cartesian_pair_if(ForwardIterator first1, ForwardIterator last1, ForwardIterator first2, ForwardIterator last2, BinaryOp op, BinaryCmp cmp)
Execute op for each pair of elements between [first1, last1) and [first2, last2) if a condition is sa...