boost::algorithm::is_partitioned() in C++ library Last Updated : 11 Jul, 2025 Summarize Comments Improve Suggest changes Share Like Article Like Report The is_partitioned() function in C++ boost library is found under the header 'boost/algorithm/cxx11/is_partitioned.hpp' which tests if the given sequence is partitioned according to the given predicate or not. Partition here means that all the items in the sequence that satisfy the predicate are at the beginning of the sequence.Syntax: bool is_partitioned ( InputIterator first, InputIterator last, Predicate p ) or bool is_partitioned ( const Range &r, Predicate p ) Parameters: The function accepts parameters as described below: first: It specifies the input iterators to the initial positions in a sequence.second: It specifies the input iterators to the final positions in a sequence.p: It specifies the comparison predicate if specified.r: It specifies the given range completely. Return Value: The function returns true if the complete sequence is sorted according to the given criteria, else it returns false. Below is the implementation of the above approach: Program-1: CPP // C++ program to implement the // above mentioned function #include <bits/stdc++.h> #include <boost/algorithm/cxx11/is_partitioned.hpp> using namespace std; // Predicate function to check // if the element is odd or not bool isOdd(int i) { return i % 2 == 1; } // Drivers code int main() { // Declares the sequence with int c[] = { 1, 2, 5, 6, 8 }; // Run the function bool ans = boost::algorithm::is_partitioned(c, isOdd); // Condition to check if (ans == 1) cout << "Sequence is partitioned"; else cout << "Sequence is not partitioned"; return 0; } Output: Sequence is not partitioned Program-2: CPP // C++ program to implement the // above mentioned function #include <bits/stdc++.h> #include <boost/algorithm/cxx11/is_partitioned.hpp> using namespace std; // Predicate function to check // if the element is odd or not bool isEven(int i) { return i % 2 == 0; } // Drivers code int main() { // Declares the sequence with int c[] = { 4, 2, 5, 6, 8 }; // Run the function bool ans = boost::algorithm::is_partitioned(c, c + 2, isEven); // Condition to check if (ans == 1) cout << "Sequence is partitioned"; else cout << "Sequence is not partitioned"; return 0; } Output: Sequence is partitioned Reference: https://www.boost.org/doc/libs/1_70_0/libs/algorithm/doc/html/the_boost_algorithm_library/CXX11/is_sorted.html Comment More infoAdvertise with us Next Article boost::algorithm::one_of() in C++ library G gopaldave Follow Improve Article Tags : C++ CPP-Functions cpp-boost Practice Tags : CPP Similar Reads boost::algorithm::is_sorted() in C++ library The is_sorted() function in C++ boost library is found under the header 'boost/algorithm/cxx11/is_sorted.hpp' which tests if the given sequence is sorted or not according to some given criteria which is specified in the predicate. If no comparison predicate is specified, then std::less is used to se 2 min read boost::algorithm::is_sorted() in C++ library The is_sorted() function in C++ boost library is found under the header 'boost/algorithm/cxx11/is_sorted.hpp' which tests if the given sequence is sorted or not according to some given criteria which is specified in the predicate. If no comparison predicate is specified, then std::less is used to se 2 min read boost::algorithm::one_of() in C++ library The one_of() function in C++ boost library is found under the header 'boost/algorithm/cxx11/one_of.hpp' which tests the elements of a sequence and returns true if exactly one of the element share the property given. It takes a sequence and a predicate, and returns true if the predicate returns true 2 min read boost::algorithm::one_of() in C++ library The one_of() function in C++ boost library is found under the header 'boost/algorithm/cxx11/one_of.hpp' which tests the elements of a sequence and returns true if exactly one of the element share the property given. It takes a sequence and a predicate, and returns true if the predicate returns true 2 min read boost::algorithm::none_of() in C++ library The none_of() function in C++ boost library is found under the header 'boost/algorithm/cxx11/none_of.hpp' which tests all the elements of a sequence and returns true if all of them do not share a property. It takes a sequence and a predicate, and returns true if the predicate returns false when appl 2 min read boost::algorithm::none_of() in C++ library The none_of() function in C++ boost library is found under the header 'boost/algorithm/cxx11/none_of.hpp' which tests all the elements of a sequence and returns true if all of them do not share a property. It takes a sequence and a predicate, and returns true if the predicate returns false when appl 2 min read Like