tetl 0.1.0
Embedded Template Library
Loading...
Searching...
No Matches
partition_point.hpp
Go to the documentation of this file.
1// SPDX-License-Identifier: BSL-1.0
2// SPDX-FileCopyrightText: Copyright (C) 2019 Tobias Hienzsch
3
4#ifndef TETL_ALGORITHM_PARTITION_POINT_HPP
5#define TETL_ALGORITHM_PARTITION_POINT_HPP
6
7namespace etl {
8
9/// \brief Examines the partitioned (as if by partition) range [first,
10/// last) and locates the end of the first partition, that is, the first
11/// element that does not satisfy p or last if all elements satisfy p.
12/// \ingroup algorithm
13template <typename ForwardIt, typename Predicate>
14[[nodiscard]] constexpr auto partition_point(ForwardIt first, ForwardIt last, Predicate p) -> ForwardIt
15{
16 for (; first != last; ++first) {
17 if (not p(*first)) {
18 break;
19 }
20 }
21
22 return first;
23}
24
25} // namespace etl
26
27#endif // TETL_ALGORITHM_PARTITION_POINT_HPP
constexpr auto partition_point(ForwardIt first, ForwardIt last, Predicate p) -> ForwardIt
Examines the partitioned (as if by partition) range [first, last) and locates the end of the first pa...
Definition partition_point.hpp:14
Definition adjacent_find.hpp:9