One particularly useful standard algorithm is std::equal , which is defined as follows:
template <typename InputIterator1, typename InputIterator2> inline bool equal(InputIterator1 start1, InputIterator1 end1, InputIterator2 start2) { while(start1 != end1) { if(*start1 != *start2) return false; ++start1; ++start2; } return true; }
The algorithm traverses the range defined by [start1, end1) and [start2, start2 + (end1 – start1)) and returns whether the elements in the range are equal. Note that the algorithm is templated by two different types of input iterators.
Why is this?
c ++ equals algorithm stl
Tika gurung
source share