34template <
typename ForwardIterator,
typename BinaryOp>
35void for_each_pair(ForwardIterator first, ForwardIterator last, BinaryOp op) {
36 while (first != last) {
37 auto next = std::next(first);
38 std::for_each(next, last, [&](
auto const &nth) { op(*first, nth); });
44template <
typename ForwardRange,
typename BinaryOp>
48 for_each_pair(begin(rng), end(rng), std::forward<BinaryOp>(op));
59template <
typename ForwardIterator,
typename BinaryOp>
61 ForwardIterator first2, ForwardIterator last2,
63 while (first1 != last1) {
64 std::for_each(first2, last2, [&](
auto const &nth) { op(*first1, nth); });
70template <
typename ForwardRange,
typename BinaryOp>
76 std::forward<BinaryOp>(op));
87template <
typename ForwardIterator,
typename BinaryOp,
typename BinaryCmp>
89 ForwardIterator first2, ForwardIterator last2,
90 BinaryOp op, BinaryCmp cmp) {
91 while (first1 != last1) {
92 std::for_each(first2, last2, [&](
auto const &nth) {
93 if (cmp(*first1, nth)) {
102template <
typename ForwardRange,
typename BinaryOp,
typename BinaryCmp>
104 BinaryOp &&op, BinaryCmp cmp) {
108 std::forward<BinaryOp>(op),
109 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...