VOOZH about

URL: https://www.geeksforgeeks.org/cpp/boostalgorithmequal-in-c-library/

⇱ boost::algorithm::equal() in C++ library - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

boost::algorithm::equal() in C++ library

Last Updated : 11 Jul, 2025
The equal() function in C++ boost library is found under the header 'boost/algorithm/cxx11/equal.hpp' tests to see if two sequences contain equal values. It returns a boolean value which determines if both the sequences are same or not. Syntax:
bool equal ( InputIterator1 first1, InputIterator1 second1,
 InputIterator2 first2, InputIterator2 second2 )
or 
bool equal ( InputIterator1 first1, InputIterator1 second1,
 InputIterator2 first2, InputIterator2 second2, 
 BinaryPredicate pred )
Parameters: The function accepts parameters as described below:
  • first1: It specifies the input iterators to the initial positions in the first sequence.
  • second1: It specifies the input iterators to the final positions in the first sequence.
    • first2: It specifies the input iterators to the initial positions in the second sequence.
    • second2: It specifies the input iterators to the final positions in the second sequence.
    • p: It specifies the comparison predicate if specified.
    Return Value: The function returns true if both the sequence are same, else it returns false. Note: The above function runs for C++14 and above. Program-1:
    Output:
    Sequence1 and Sequence2 are equal
    
    Program-2:
Comment
Article Tags: