algorithm.hpp Source File

algorithm.hpp Source File#

Composable Kernel: 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
11namespace ck {
12namespace ranges {
13template <typename InputRange, typename OutputIterator>
14auto 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
24template <typename T, typename OutputRange>
25auto 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
35template <typename InputRange, typename OutputIterator, typename UnaryOperation>
36auto 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
Definition algorithm.hpp:12
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:268