alpaka
Abstraction Library for Parallel Kernel Acceleration
Loading...
Searching...
No Matches
Fold.hpp
Go to the documentation of this file.
1/* Copyright 2022 Axel Huebl, Benjamin Worpitz, Jan Stephan, Bernhard Manfred Gruber
2 * SPDX-License-Identifier: MPL-2.0
3 */
4
5#pragma once
6
8
9namespace alpaka::meta
10{
12 template<typename TFnObj, typename T>
13 ALPAKA_FN_HOST_ACC constexpr auto foldr(TFnObj const& /* f */, T const& t) -> T
14 {
15 return t;
16 }
17
19 template<typename TFnObj, typename T0, typename T1, typename... Ts>
20 ALPAKA_FN_HOST_ACC constexpr auto foldr(TFnObj const& f, T0 const& t0, T1 const& t1, Ts const&... ts)
21 {
22 return f(t0, foldr(f, t1, ts...));
23 }
24} // namespace alpaka::meta
#define ALPAKA_FN_HOST_ACC
Definition Common.hpp:39
#define ALPAKA_NO_HOST_ACC_WARNING
Disable nvcc warning: 'calling a host function from host device function.' Usage: ALPAKA_NO_HOST_ACC_...
Definition Common.hpp:82
ALPAKA_NO_HOST_ACC_WARNING ALPAKA_FN_HOST_ACC constexpr auto foldr(TFnObj const &, T const &t) -> T
Definition Fold.hpp:13