alpaka
Abstraction Library for Parallel Kernel Acceleration
IsArrayOrVector.hpp
Go to the documentation of this file.
1 /* Copyright 2022 Jiri Vyskocil, Bernhard Manfred Gruber
2  * SPDX-License-Identifier: MPL-2.0
3  */
4 
5 #pragma once
6 
7 #include "alpaka/vec/Vec.hpp"
8 
9 #include <functional>
10 #include <numeric>
11 #include <type_traits>
12 #include <vector>
13 
14 namespace alpaka::meta
15 {
16  /** Checks whether T is an array or a vector type
17  *
18  * @tparam T a type to check
19  */
20  template<typename T>
21  struct IsArrayOrVector : std::false_type
22  {
23  };
24 
25  /** Specialization of \a IsArrayOrVector for vector types
26  *
27  * @tparam T inner type held in the vector
28  * @tparam A vector allocator
29  */
30  template<typename T, typename A>
31  struct IsArrayOrVector<std::vector<T, A>> : std::true_type
32  {
33  };
34 
35  /** Specialization of \a IsArrayOrVector for plain arrays
36  *
37  * @tparam T inner type held in the array
38  * @tparam N size of the array
39  */
40  template<typename T, std::size_t N>
41  struct IsArrayOrVector<T[N]> : std::true_type
42  {
43  };
44 
45  /** Specialization of \a IsArrayOrVector for std::array
46  *
47  * @tparam T inner type held in the array
48  * @tparam N size of the array
49  */
50  template<typename T, std::size_t N>
51  struct IsArrayOrVector<std::array<T, N>> : std::true_type
52  {
53  };
54 
55  /** Specialization of \a IsArrayOrVector for alpaka::Vec
56  *
57  * @tparam T inner type held in the array
58  * @tparam N size of the array
59  */
60  template<typename T, typename N>
61  struct IsArrayOrVector<alpaka::Vec<N, T>> : std::true_type
62  {
63  };
64 
65 } // namespace alpaka::meta
A n-dimensional vector.
Definition: Vec.hpp:38
The alpaka accelerator library.