VOOZH about

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

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


  • Courses
  • Tutorials
  • Interview Prep

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

Last Updated : 11 Jul, 2025

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
 


Output: 
Sequence is not partitioned

 

Program-2
 

Comment
Article Tags: