NumCpp  2.11.0
A Templatized Header Only C++ Implementation of the Python NumPy Library
TypeTraits.hpp
Go to the documentation of this file.
1 #pragma once
29 
30 #include <complex>
31 #include <type_traits>
32 
33 namespace nc
34 {
35  //============================================================================
36  // Class Description:
39  template<typename... Ts>
41 
42  //============================================================================
43  // Class Description:
46  template<typename Head, typename... Tail>
47  struct all_arithmetic<Head, Tail...>
48  {
49  static constexpr bool value = std::is_arithmetic<Head>::value && all_arithmetic<Tail...>::value;
50  };
51 
52  //============================================================================
53  // Class Description:
56  template<typename T>
57  struct all_arithmetic<T>
58  {
59  static constexpr bool value = std::is_arithmetic<T>::value;
60  };
61 
62  //============================================================================
63  // Class Description:
66  template<typename... Ts>
67  constexpr bool all_arithmetic_v = all_arithmetic<Ts...>::value;
68 
69  //============================================================================
70  // Class Description:
73  template<typename T1, typename... Ts>
74  struct all_same;
75 
76  //============================================================================
77  // Class Description:
80  template<typename T1, typename Head, typename... Tail>
81  struct all_same<T1, Head, Tail...>
82  {
83  static constexpr bool value = std::is_same<T1, Head>::value && all_same<T1, Tail...>::value;
84  };
85 
86  //============================================================================
87  // Class Description:
90  template<typename T1, typename T2>
91  struct all_same<T1, T2>
92  {
93  static constexpr bool value = std::is_same<T1, T2>::value;
94  };
95 
96  //============================================================================
97  // Class Description:
100  template<typename... Ts>
101  constexpr bool all_same_v = all_same<Ts...>::value;
102 
103  //============================================================================
104  // Class Description:
107  template<typename dtype>
109  {
110  static constexpr bool value =
111  std::is_default_constructible<dtype>::value && std::is_nothrow_copy_constructible<dtype>::value &&
112  std::is_nothrow_move_constructible<dtype>::value && std::is_nothrow_copy_assignable<dtype>::value &&
113  std::is_nothrow_move_assignable<dtype>::value && std::is_nothrow_destructible<dtype>::value &&
114  !std::is_void<dtype>::value && !std::is_pointer<dtype>::value && !std::is_array<dtype>::value &&
115  !std::is_union<dtype>::value && !std::is_function<dtype>::value && !std::is_abstract<dtype>::value;
116  };
117 
118  //============================================================================
119  // Class Description:
122  template<class dtype>
124 
125  // Forward declare
126  template<typename dtype, class Allocator>
127  class NdArray;
128 
129  //============================================================================
130  // Class Description:
133  template<typename>
134  struct is_ndarray_int : std::false_type
135  {
136  };
137 
138  //============================================================================
139  // Class Description:
142 
143  template<typename dtype, typename Allocator>
144  struct is_ndarray_int<NdArray<dtype, Allocator>>
145  {
146  static constexpr bool value = std::is_integral_v<dtype>;
147  };
148 
149  //============================================================================
150  // Class Description:
153  template<typename T>
155 
156  //============================================================================
157  // Class Description:
160  template<typename T>
161  using ndarray_int_concept = std::enable_if_t<is_ndarray_int_v<T>, int>;
162 
163  //============================================================================
164  // Class Description:
167  template<class T>
168  struct is_complex
169  {
170  static constexpr bool value = false;
171  };
172 
173  //============================================================================
174  // Class Description:
177  template<class T>
178  struct is_complex<std::complex<T>>
179  {
180  static constexpr bool value = true;
181  };
182 
183  //============================================================================
184  // Class Description:
187  template<class T>
189 
190  //============================================================================
191  // Class Description:
194  template<std::size_t Value1, std::size_t Value2>
195  struct greaterThan
196  {
197  static constexpr bool value = Value1 > Value2;
198  };
199 
200  //============================================================================
201  // Class Description:
204  template<std::size_t Value1, std::size_t Value2>
206 } // namespace nc
Holds 1D and 2D arrays, the main work horse of the NumCpp library.
Definition: NdArrayCore.hpp:138
Definition: Cartesian.hpp:40
constexpr bool all_arithmetic_v
Definition: TypeTraits.hpp:67
constexpr bool is_ndarray_int_v
Definition: TypeTraits.hpp:154
constexpr bool greaterThan_v
Definition: TypeTraits.hpp:205
std::enable_if_t< is_ndarray_int_v< T >, int > ndarray_int_concept
Definition: TypeTraits.hpp:161
auto complex(dtype inReal)
Definition: complex.hpp:47
constexpr bool is_valid_dtype_v
Definition: TypeTraits.hpp:123
constexpr bool all_same_v
Definition: TypeTraits.hpp:101
constexpr bool is_complex_v
Definition: TypeTraits.hpp:188
Definition: TypeTraits.hpp:40
Definition: TypeTraits.hpp:74
Definition: TypeTraits.hpp:196
static constexpr bool value
Definition: TypeTraits.hpp:197
Definition: TypeTraits.hpp:169
static constexpr bool value
Definition: TypeTraits.hpp:170
Definition: TypeTraits.hpp:135
Definition: TypeTraits.hpp:109
static constexpr bool value
Definition: TypeTraits.hpp:110