alpaka
Abstraction Library for Parallel Kernel Acceleration
Filter.hpp
Go to the documentation of this file.
1 /* Copyright 2022 Benjamin Worpitz, Bernhard Manfred Gruber
2  * SPDX-License-Identifier: MPL-2.0
3  */
4 
5 #pragma once
6 
8 
9 #include <type_traits>
10 
11 namespace alpaka::meta
12 {
13  namespace detail
14  {
15  template<template<typename...> class TList, template<typename...> class TPred, typename... Ts>
17 
18  template<template<typename...> class TList, template<typename...> class TPred>
19  struct FilterImplHelper<TList, TPred>
20  {
21  using type = TList<>;
22  };
23 
24  template<template<typename...> class TList, template<typename...> class TPred, typename T, typename... Ts>
25  struct FilterImplHelper<TList, TPred, T, Ts...>
26  {
27  using type = std::conditional_t<
28  TPred<T>::value,
29  Concatenate<TList<T>, typename FilterImplHelper<TList, TPred, Ts...>::type>,
30  typename FilterImplHelper<TList, TPred, Ts...>::type>;
31  };
32 
33  template<typename TList, template<typename...> class TPred>
34  struct FilterImpl;
35 
36  template<template<typename...> class TList, template<typename...> class TPred, typename... Ts>
37  struct FilterImpl<TList<Ts...>, TPred>
38  {
39  using type = typename detail::FilterImplHelper<TList, TPred, Ts...>::type;
40  };
41  } // namespace detail
42 
43  /// \tparam TPred Only the first parameter is used, all other must be set by TPred to some default.
44  /// Using '...' instead of a single type is a workaround for CrayClang.
45  template<typename TList, template<typename...> class TPred>
47 } // namespace alpaka::meta
typename detail::FilterImpl< TList, TPred >::type Filter
Definition: Filter.hpp:46
typename detail::ConcatenateImpl< T... >::type Concatenate
Definition: Concatenate.hpp:28
std::conditional_t< TPred< T >::value, Concatenate< TList< T >, typename FilterImplHelper< TList, TPred, Ts... >::type >, typename FilterImplHelper< TList, TPred, Ts... >::type > type
Definition: Filter.hpp:30
typename detail::FilterImplHelper< TList, TPred, Ts... >::type type
Definition: Filter.hpp:39