Stratax
Scientific computing containers and operations
Loading...
Searching...
No Matches
Concepts.hpp
Go to the documentation of this file.
1#pragma once
2
3#include <concepts>
4#include <complex>
5#include <type_traits>
6
7#include "Types.hpp"
8
10
16template<typename T>
17using clean_t = std::remove_cvref_t<T>;
18
19template<typename T, typename... Candidates>
20concept SameAsAny =
21 (std::same_as<clean_t<T>, Candidates> || ...);
22
23template<typename T>
26 T,
27 char,
28 signed char,
29 unsigned char,
30 wchar_t,
31 char8_t,
32 char16_t,
33 char32_t>;
34
35template<typename T>
36concept BoolLike =
37 std::same_as<clean_t<T>, bool>;
38
39template<typename T>
42 T,
43 std::complex<float>,
44 std::complex<double>,
45 std::complex<long double>>;
46
47}
48
54template<typename T>
55concept Integral =
56 std::integral<stratax::core::concept_detail::clean_t<T>> &&
59
68template<typename T>
69concept Integer =
71
80template<typename T>
83 std::signed_integral<stratax::core::concept_detail::clean_t<T>>;
84
92template<typename T>
95 std::unsigned_integral<stratax::core::concept_detail::clean_t<T>>;
96
102template<typename T>
103concept Floating =
104 std::floating_point<stratax::core::concept_detail::clean_t<T>>;
105
111template<typename T>
112concept Float =
114
120template<typename T>
121concept Arithmetic =
122 Integral<T> ||
124
133template<typename T>
134concept Real =
136
142template<typename T>
143concept Complex =
145
151template<typename T>
152concept Numeric =
155
161template<typename T>
162concept Scalar =
164
165namespace stratax::container {
166
167template<typename T>
168requires Numeric<T>
169class Vector;
170
171template<typename T>
172requires Numeric<T>
173class Matrix;
174
175template<typename T>
176requires Numeric<T>
177class Tensor;
178
179}
180
186template<typename T>
187struct is_array : std::false_type {};
188
189template<typename T>
190requires Numeric<T>
191struct is_array<stratax::container::Vector<T>> : std::true_type {};
192
193template<typename T>
194requires Numeric<T>
195struct is_array<stratax::container::Matrix<T>> : std::true_type {};
196
197template<typename T>
198requires Numeric<T>
199struct is_array<stratax::container::Tensor<T>> : std::true_type {};
200
201template<typename T>
202concept Array =
204
210template<typename T>
211concept NDarray =
213{
214 a.shape();
215 a.size();
216
217 a.begin();
218 a.end();
219};
Matches arithmetic scalar types.
Definition Concepts.hpp:121
Matches supported complex scalar types.
Definition Concepts.hpp:143
Alias for Stratax-supported floating-point types.
Definition Concepts.hpp:112
Matches floating-point types.
Definition Concepts.hpp:103
Alias for Stratax-supported integer types.
Definition Concepts.hpp:69
Matches signed and unsigned integral types, excluding character-like types.
Definition Concepts.hpp:55
Matches array-like container types with shape, size, and iteration support.
Definition Concepts.hpp:211
Matches all scalar types supported by Stratax numeric containers.
Definition Concepts.hpp:152
Matches real numeric scalar types.
Definition Concepts.hpp:134
Alias for any scalar type accepted by Stratax numeric containers.
Definition Concepts.hpp:162
Matches supported signed integer types.
Definition Concepts.hpp:81
Matches supported unsigned integer types.
Definition Concepts.hpp:93
std::remove_cvref_t< T > clean_t
Removes cv-qualifiers and references from a type.
Definition Concepts.hpp:17
Type trait that reports whether a type is a Stratax array.
Definition Concepts.hpp:187