# 11 Algorithms library [algorithms]

## 11.3 Non-modifying sequence operations [alg.nonmodifying]

### 11.3.11 Equal [alg.equal]

``` template <InputIterator I1, Sentinel<I1> S1, InputIterator I2, Sentinel<I2> S2, class Pred = equal_to<>, class Proj1 = identity, class Proj2 = identity> requires IndirectlyComparable<I1, I2, Pred, Proj1, Proj2> bool equal(I1 first1, S1 last1, I2 first2, S2 last2, Pred pred = Pred{}, Proj1 proj1 = Proj1{}, Proj2 proj2 = Proj2{}); template <InputRange Rng1, InputRange Rng2, class Pred = equal_to<>, class Proj1 = identity, class Proj2 = identity> requires IndirectlyComparable<iterator_t<Rng1>, iterator_t<Rng2>, Pred, Proj1, Proj2> bool equal(Rng1&& rng1, Rng2&& rng2, Pred pred = Pred{}, Proj1 proj1 = Proj1{}, Proj2 proj2 = Proj2{}); ```

Returns: If last1 - first1 != last2 - first2, return false. Otherwise return true if for every iterator i in the range [first1,last1) the following condition holds: invoke(pred, invoke(proj1, *i), invoke(proj2, *(first2 + (i - first1)))). Otherwise, returns false.

Complexity: No applications of the corresponding predicate and projections if:

• SizedSentinel<S1, I1> is satisfied, and

• SizedSentinel<S2, I2> is satisfied, and

• last1 - first1 != last2 - first2.

Otherwise, at most min(last1 - first1, last2 - first2) applications of the corresponding predicate and projections.