tetl 0.1.0
Embedded Template Library
Loading...
Searching...
No Matches
partition_copy.hpp
Go to the documentation of this file.
1// SPDX-License-Identifier: BSL-1.0
2
3#ifndef TETL_ALGORITHM_PARTITION_COPY_HPP
4#define TETL_ALGORITHM_PARTITION_COPY_HPP
5
7
8namespace etl {
9
18template <typename InputIt, typename OutputIt1, typename OutputIt2, typename Predicate>
19constexpr auto
20partition_copy(InputIt first, InputIt last, OutputIt1 destinationTrue, OutputIt2 destinationFalse, Predicate p)
22{
23 for (; first != last; ++first) {
24 if (p(*first)) {
25 *destinationTrue = *first;
26 ++destinationTrue;
27 } else {
28 *destinationFalse = *first;
29 ++destinationFalse;
30 }
31 }
32
33 return {destinationTrue, destinationFalse};
34}
35
36} // namespace etl
37
38#endif // TETL_ALGORITHM_PARTITION_COPY_HPP
constexpr auto partition_copy(InputIt first, InputIt last, OutputIt1 destinationTrue, OutputIt2 destinationFalse, Predicate p) -> pair< OutputIt1, OutputIt2 >
Copies the elements from the range [first, last) to two different ranges depending on the value retur...
Definition partition_copy.hpp:20
Definition adjacent_find.hpp:8
etl::pair is a class template that provides a way to store two heterogeneous objects as a single unit...
Definition pair.hpp:36