diff options
Diffstat (limited to 'libstdc++-v3/include/bits/stl_algo.h')
-rw-r--r-- | libstdc++-v3/include/bits/stl_algo.h | 34 |
1 files changed, 26 insertions, 8 deletions
diff --git a/libstdc++-v3/include/bits/stl_algo.h b/libstdc++-v3/include/bits/stl_algo.h index 43b0582db74..f0199a43946 100644 --- a/libstdc++-v3/include/bits/stl_algo.h +++ b/libstdc++-v3/include/bits/stl_algo.h @@ -730,8 +730,8 @@ _GLIBCXX_BEGIN_NAMESPACE(std) #ifdef __GXX_EXPERIMENTAL_CXX0X__ /** - * @brief Checks that a predicate is true for all the elements - * of a sequence. + * @brief Checks that a predicate is true for all the elements + * of a sequence. * @param first An input iterator. * @param last An input iterator. * @param pred A predicate. @@ -746,8 +746,8 @@ _GLIBCXX_BEGIN_NAMESPACE(std) { return __last == std::find_if_not(__first, __last, __pred); } /** - * @brief Checks that a predicate is false for all the elements - * of a sequence. + * @brief Checks that a predicate is false for all the elements + * of a sequence. * @param first An input iterator. * @param last An input iterator. * @param pred A predicate. @@ -762,8 +762,8 @@ _GLIBCXX_BEGIN_NAMESPACE(std) { return __last == _GLIBCXX_STD_P::find_if(__first, __last, __pred); } /** - * @brief Checks that a predicate is false for at least an element - * of a sequence. + * @brief Checks that a predicate is false for at least an element + * of a sequence. * @param first An input iterator. * @param last An input iterator. * @param pred A predicate. @@ -778,8 +778,8 @@ _GLIBCXX_BEGIN_NAMESPACE(std) { return !std::none_of(__first, __last, __pred); } /** - * @brief Find the first element in a sequence for which a - * predicate is false. + * @brief Find the first element in a sequence for which a + * predicate is false. * @param first An input iterator. * @param last An input iterator. * @param pred A predicate. @@ -799,6 +799,24 @@ _GLIBCXX_BEGIN_NAMESPACE(std) return std::__find_if_not(__first, __last, __pred, std::__iterator_category(__first)); } + + /** + * @brief Checks whether the sequence is partitioned. + * @param first An input iterator. + * @param last An input iterator. + * @param pred A predicate. + * @return True if the range @p [first,last) is partioned by @p pred, + * i.e. if all elements that satisfy @p pred appear before those that + * do not. + */ + template<typename _InputIterator, typename _Predicate> + inline bool + is_partitioned(_InputIterator __first, _InputIterator __last, + _Predicate __pred) + { + __first = std::find_if_not(__first, __last, __pred); + return std::none_of(__first, __last, __pred); + } #endif |