boost::algorithm::equal() in C++ library Last Updated : 17 Jun, 2019 Comments Improve Suggest changes Like Article Like Report 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: CPP14 // C++ program to implement the // above mentioned function #include <bits/stdc++.h> #include <boost/algorithm/cxx14/equal.hpp> using namespace std; // Drivers code int main() { // Declares the sequences int a[] = { 1, 2, 5, 6, 8 }; int b[] = { 1, 2, 5, 6, 8 }; // Run the function bool ans = boost::algorithm::equal(a, a + 5, b, b + 5); // Condition to check if (ans == 1) cout << "Sequence1 and Sequence2 are equal"; else cout << "Sequence1 and Sequence2 are not equal"; return 0; } Output: Sequence1 and Sequence2 are equal Program-2: CPP14 // C++ program to implement the // above mentioned function #include <bits/stdc++.h> #include <boost/algorithm/cxx14/equal.hpp> using namespace std; // Drivers code int main() { // Declares the sequences int a[] = { 1, 2, 5, 6, 8 }; int b[] = { 1, 2, 5 }; // Run the function bool ans = boost::algorithm::equal(a, a + 5, b, b + 5); // Condition to check if (ans == 1) cout << "Sequence1 and Sequence2 are equal"; else cout << "Sequence1 and Sequence2 are not equal"; return 0; } Output: Sequence1 and Sequence2 are not equal Reference: https://www.boost.org/doc/libs/1_70_0/libs/algorithm/doc/html/algorithm/CXX14.html#the_boost_algorithm_library.CXX14.equal Comment More infoAdvertise with us Next Article boost::algorithm::equal() in C++ library G gopaldave Follow Improve Article Tags : C++ CPP-Functions cpp-boost Practice Tags : CPP Similar Reads boost::algorithm::one_of_equal() in C++ library The one_of_equal() function in C++ boost library is found under the header 'boost/algorithm/cxx11/one_of.hpp' which tests if exactly one of the elements of a sequence against the value passed is same. It takes a sequence and a value, and returns true if the exactly one of the elements are same in th 2 min read boost::algorithm::all_of_equal() in C++ library The all_of_equal() function in C++ boost library is found under the header 'boost/algorithm/cxx11/all_of.hpp' which tests all the elements of a sequence against the value passed in the parameter and returns true if all the elements of the sequence are same. It takes a sequence and a value, and retur 2 min read boost::algorithm::any_of_equal() in C++ library The any_of_equal() function in C++ boost library is found under the header 'boost/algorithm/cxx11/any_of.hpp' which tests if any of the elements of a sequence against the value passed is same. It takes a sequence and a value, and returns true if the any of the elements are same in the sequence to th 2 min read boost::algorithm::none_of_equal() in C++ library The none_of_equal() function in C++ boost library is found under the header 'boost/algorithm/cxx11/none_of.hpp' which tests all the elements of a sequence against the value passed in the parameter and returns true if all the elements of the sequence are not equal to the value passed. It takes a sequ 2 min read boost::algorithm::clamp() in C++ library The clamp() function in C++ boost library is found under the header 'boost/algorithm/clamp.hpp' contains two functions for "clamping" a value between a pair of boundary values. Syntax: const T& clamp ( const T& val, const T& lo, const T& hi ) or const T& clamp ( const T& valu 2 min read Like