tetl 0.1.0
Embedded Template Library
Loading...
Searching...
No Matches
transform.hpp
Go to the documentation of this file.
1// SPDX-License-Identifier: BSL-1.0
2
3#ifndef TETL_ALGORITHM_TRANSFORM_HPP
4#define TETL_ALGORITHM_TRANSFORM_HPP
5
6namespace etl {
7
10
23template <typename InputIt, typename OutputIt, typename UnaryOp>
24constexpr auto transform(InputIt first, InputIt last, OutputIt dest, UnaryOp op) -> OutputIt
25{
26 for (; first != last; ++first, (void)++dest) {
27 *dest = op(*first);
28 }
29 return dest;
30}
31
32template <typename InputIt1, typename InputIt2, typename OutputIt, typename BinaryOp>
33constexpr auto transform(InputIt1 first1, InputIt1 last1, InputIt2 first2, OutputIt dest, BinaryOp op) -> OutputIt
34{
35 for (; first1 != last1; ++first1, (void)++first2, ++dest) {
36 *dest = op(*first1, *first2);
37 }
38 return dest;
39}
40
42
43} // namespace etl
44
45#endif // TETL_ALGORITHM_TRANSFORM_HPP
constexpr auto transform(InputIt first, InputIt last, OutputIt dest, UnaryOp op) -> OutputIt
Applies the given function to a range and stores the result in another range, beginning at dest....
Definition transform.hpp:24
Definition adjacent_find.hpp:8