tetl 0.1.0
Embedded Template Library
Loading...
Searching...
No Matches
is_partitioned.hpp
Go to the documentation of this file.
1// SPDX-License-Identifier: BSL-1.0
2
3#ifndef TETL_ALGORITHM_IS_PARTITIONED_HPP
4#define TETL_ALGORITHM_IS_PARTITIONED_HPP
5
6namespace etl {
7
15template <typename InputIt, typename Predicate>
16[[nodiscard]] constexpr auto is_partitioned(InputIt first, InputIt last, Predicate p) -> bool
17{
18 for (; first != last; ++first) {
19 if (not p(*first)) {
20 break;
21 }
22 }
23
24 for (; first != last; ++first) {
25 if (p(*first)) {
26 return false;
27 }
28 }
29
30 return true;
31}
32
33} // namespace etl
34
35#endif // TETL_ALGORITHM_IS_PARTITIONED_HPP
constexpr auto is_partitioned(InputIt first, InputIt last, Predicate p) -> bool
Returns true if all elements in the range [first, last) that satisfy the predicate p appear before al...
Definition is_partitioned.hpp:16
Definition adjacent_find.hpp:8