alpaka
Abstraction Library for Parallel Kernel Acceleration
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 
7 #include "alpaka/core/Common.hpp"
8 
9 namespace 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 constexpr ALPAKA_FN_HOST_ACC auto foldr(TFnObj const &, T const &t) -> T
Definition: Fold.hpp:13