tetl 0.1.0
Embedded Template Library
Loading...
Searching...
No Matches
remove_copy_if.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_REMOVE_COPY_IF_HPP
5#define TETL_ALGORITHM_REMOVE_COPY_IF_HPP
6
7namespace etl {
8
9/// \brief Copies elements from the range [first, last), to another range
10/// beginning at destination, omitting the elements which satisfy specific
11/// criteria. Source and destination ranges cannot overlap. Ignores all elements
12/// for which predicate p returns true.
13/// \returns Iterator to the element past the last element copied.
14/// \ingroup algorithm
15template <typename InputIt, typename OutputIt, typename Predicate>
16constexpr auto remove_copy_if(InputIt first, InputIt last, OutputIt destination, Predicate p) -> OutputIt
17{
18 for (; first != last; ++first, (void)++destination) {
19 if (not p(*first)) {
20 *destination = *first;
21 }
22 }
23
24 return destination;
25}
26
27} // namespace etl
28
29#endif // TETL_ALGORITHM_REMOVE_COPY_IF_HPP
constexpr auto remove_copy_if(InputIt first, InputIt last, OutputIt destination, Predicate p) -> OutputIt
Copies elements from the range [first, last), to another range beginning at destination,...
Definition remove_copy_if.hpp:16
Definition adjacent_find.hpp:9