tetl 0.1.0
Embedded Template Library
Loading...
Searching...
No Matches
unique_copy.hpp
Go to the documentation of this file.
1// SPDX-License-Identifier: BSL-1.0
2
3#ifndef TETL_ALGORITHM_UNIQUE_COPY_HPP
4#define TETL_ALGORITHM_UNIQUE_COPY_HPP
5
7
8namespace etl {
9
12
19template <typename InputIt, typename OutputIt, typename Predicate>
20constexpr auto unique_copy(InputIt first, InputIt last, OutputIt destination, Predicate pred) -> OutputIt
21{
22 if (first != last) {
23 *destination = *first;
24
25 while (++first != last) {
26 if (not pred(*destination, *first)) {
27 *++destination = *first;
28 }
29 }
30
31 ++destination;
32 }
33
34 return destination;
35}
36
37template <typename InputIt, typename OutputIt>
38constexpr auto unique_copy(InputIt first, InputIt last, OutputIt destination) -> OutputIt
39{
40 return etl::unique_copy(first, last, destination, etl::equal_to());
41}
42
44
45} // namespace etl
46
47#endif // TETL_ALGORITHM_UNIQUE_COPY_HPP
constexpr auto unique_copy(InputIt first, InputIt last, OutputIt destination, Predicate pred) -> OutputIt
Copies the elements from the range [first, last), to another range beginning at d_first in such a way...
Definition unique_copy.hpp:20
Definition adjacent_find.hpp:8
Function object for performing comparisons. Unless specialised, invokes operator== on type T....
Definition equal_to.hpp:14