/home/docs/checkouts/readthedocs.org/user_builds/advanced-micro-devices-composable-kernel/checkouts/develop/include/ck/library/utility/algorithm.hpp Source File

/home/docs/checkouts/readthedocs.org/user_builds/advanced-micro-devices-composable-kernel/checkouts/develop/include/ck/library/utility/algorithm.hpp Source File#

Composable Kernel: /home/docs/checkouts/readthedocs.org/user_builds/advanced-micro-devices-composable-kernel/checkouts/develop/include/ck/library/utility/algorithm.hpp Source File
algorithm.hpp
Go to the documentation of this file.
1 // SPDX-License-Identifier: MIT
2 // Copyright (c) 2018-2023, Advanced Micro Devices, Inc. All rights reserved.
3 
4 #pragma once
5 
6 #include <algorithm>
7 #include <iterator>
8 #include <type_traits>
9 #include <utility>
10 
11 namespace ck {
12 namespace ranges {
13 template <typename InputRange, typename OutputIterator>
14 auto copy(InputRange&& range,
15  OutputIterator iter) -> decltype(std::copy(std::begin(std::forward<InputRange>(range)),
16  std::end(std::forward<InputRange>(range)),
17  iter))
18 {
19  return std::copy(std::begin(std::forward<InputRange>(range)),
20  std::end(std::forward<InputRange>(range)),
21  iter);
22 }
23 
24 template <typename T, typename OutputRange>
25 auto fill(OutputRange&& range, const T& init)
26  -> std::void_t<decltype(std::fill(std::begin(std::forward<OutputRange>(range)),
27  std::end(std::forward<OutputRange>(range)),
28  init))>
29 {
30  std::fill(std::begin(std::forward<OutputRange>(range)),
31  std::end(std::forward<OutputRange>(range)),
32  init);
33 }
34 
35 template <typename InputRange, typename OutputIterator, typename UnaryOperation>
36 auto transform(InputRange&& range, OutputIterator iter, UnaryOperation unary_op)
37  -> decltype(std::transform(std::begin(range), std::end(range), iter, unary_op))
38 {
39  return std::transform(std::begin(range), std::end(range), iter, unary_op);
40 }
41 
42 } // namespace ranges
43 } // namespace ck
auto fill(OutputRange &&range, const T &init) -> std::void_t< decltype(std::fill(std::begin(std::forward< OutputRange >(range)), std::end(std::forward< OutputRange >(range)), init))>
Definition: algorithm.hpp:25
auto transform(InputRange &&range, OutputIterator iter, UnaryOperation unary_op) -> decltype(std::transform(std::begin(range), std::end(range), iter, unary_op))
Definition: algorithm.hpp:36
auto copy(InputRange &&range, OutputIterator iter) -> decltype(std::copy(std::begin(std::forward< InputRange >(range)), std::end(std::forward< InputRange >(range)), iter))
Definition: algorithm.hpp:14
Definition: ck.hpp:267