Maipa's Standard Library Extension 1.5.6
mstd
Loading...
Searching...
No Matches
arithmetic_types.hpp
1/*
2 * mstd - Maipa's Standard Library
3 *
4 * Licensed under the BSD 3-Clause License with Attribution Requirement.
5 * See the LICENSE file for details: https://github.com/MAIPA01/mstd/blob/main/LICENSE
6 *
7 * Copyright (c) 2025, Patryk Antosik (MAIPA01)
8 */
9
10#pragma once
11#ifndef _MSTD_ARITHMETIC_TYPES_HPP_
12 #define _MSTD_ARITHMETIC_TYPES_HPP_
13
14 #include <mstd/config.hpp>
15
17_MSTD_WARNING("this is only available for c++17 and greater!");
18 #else
19
20 #include <mstd/arithmetic_utils.hpp>
21 #include <mstd/management_types.hpp>
22
23namespace mstd {
25 template<size_t N, arithmetic T>
26 requires (N > 0)
27 class vec;
28
29 template<arithmetic T = float>
30 class quat;
31
32 template<size_t C, size_t R, arithmetic T>
33 requires (C > 0 && R > 0)
34 class mat;
35 #else
36 template<size_t N, class T, std::enable_if_t<(N > 0 && std::is_arithmetic_v<T>), bool> = true>
37 class vec;
38
39 template<class T = float, std::enable_if_t<std::is_arithmetic_v<T>, bool> = true>
40 class quat;
41
42 template<size_t C, size_t R, class T, std::enable_if_t<(C > 0 && R > 0 && std::is_arithmetic_v<T>), bool> = true>
43 class mat;
44 #endif
45
46 #pragma region PREDEFINED_QUATS
47 using fquat = quat<float>;
48 using dquat = quat<double>;
49 using ldquat = quat<long double>;
50 using iquat = quat<int>;
51 using uquat = quat<unsigned int>;
52 using bquat = quat<bool>;
53 using cquat = quat<char>;
54 using ucquat = quat<unsigned char>;
55 using scquat = quat<signed char>;
56 using lquat = quat<long>;
57 using ulquat = quat<unsigned long>;
58 using llquat = quat<long long>;
59 using ullquat = quat<unsigned long long>;
60 #pragma endregion
61
62 #pragma region PREDEFINED_VECS
63 #define _MSTD_MAKE_VECS_TYPES(len)
64 using vec##len = vec<len, float>;
65 using fvec##len = vec<len, float>;
66 using dvec##len = vec<len, double>;
67 using ldvec##len = vec<len, long double>;
68 using ivec##len = vec<len, int>;
69 using uvec##len = vec<len, unsigned int>;
70 using bvec##len = vec<len, bool>;
71 using cvec##len = vec<len, char>;
72 using ucvec##len = vec<len, unsigned char>;
73 using scvec##len = vec<len, signed char>;
74 using lvec##len = vec<len, long>;
75 using ulvec##len = vec<len, unsigned long>;
76 using llvec##len = vec<len, long long>;
77 using ullvec##len = vec<len, unsigned long long>
78
82 #pragma endregion
83
84 #pragma region PREDEFINED_MATS
85 #define _MSTD_MAKE_MAT_NOT_SQR_TYPES(col, row)
86 using mat##col##x##row = mat<col, row, float>;
87 using fmat##col##x##row = mat<col, row, float>;
88 using dmat##col##x##row = mat<col, row, double>;
89 using ldmat##col##x##row = mat<col, row, long double>;
90 using imat##col##x##row = mat<col, row, int>;
91 using umat##col##x##row = mat<col, row, unsigned int>;
92 using bmat##col##x##row = mat<col, row, bool>;
93 using cmat##col##x##row = mat<col, row, char>;
94 using ucmat##col##x##row = mat<col, row, unsigned char>;
95 using scmat##col##x##row = mat<col, row, signed char>;
96 using lmat##col##x##row = mat<col, row, long>;
97 using ulmat##col##x##row = mat<col, row, unsigned long>;
98 using llmat##col##x##row = mat<col, row, long long>;
99 using ullmat##col##x##row = mat<col, row, unsigned long long>
100
101 #define _MSTD_MAKE_TWO_MAT_NOT_SQR_TYPES(col, row)
104
108
109 template<size_t N, class T>
110 using mat_sqr = mat<N, N, T>;
111
112 #define _MSTD_MAKE_MAT_SQR_TYPES(len)
113 using mat##len = mat_sqr<len, float>;
114 using fmat##len = mat_sqr<len, float>;
115 using dmat##len = mat_sqr<len, double>;
116 using ldmat##len = mat_sqr<len, long double>;
117 using imat##len = mat_sqr<len, int>;
118 using umat##len = mat_sqr<len, unsigned int>;
119 using bmat##len = mat_sqr<len, bool>;
120 using cmat##len = mat_sqr<len, char>;
121 using ucmat##len = mat_sqr<len, unsigned char>;
122 using scmat##len = mat_sqr<len, signed char>;
123 using lmat##len = mat_sqr<len, long>;
124 using ulmat##len = mat_sqr<len, unsigned long>;
125 using llmat##len = mat_sqr<len, long long>;
126 using ullmat##len = mat_sqr<len, unsigned long long>
127
131 #pragma endregion
132} // namespace mstd
133 #endif
134#endif
#define _MSTD_MAKE_MAT_SQR_TYPES(len)
Definition arithmetic_types.hpp:112
#define _MSTD_MAKE_MAT_NOT_SQR_TYPES(col, row)
Definition arithmetic_types.hpp:85
#define _MSTD_MAKE_TWO_MAT_NOT_SQR_TYPES(col, row)
Definition arithmetic_types.hpp:101
#define _MSTD_MAKE_VECS_TYPES(len)
Definition arithmetic_types.hpp:63
#define _MSTD_HAS_CXX17
Definition config.hpp:45
#define _MSTD_HAS_CXX20
Definition config.hpp:52
Definition arithmetic_types.hpp:23
quat< unsigned long > ulquat
Definition arithmetic_types.hpp:57
quat< float > fquat
Definition arithmetic_types.hpp:47
quat< long > lquat
Definition arithmetic_types.hpp:56
quat< unsigned long long > ullquat
Definition arithmetic_types.hpp:59
quat< double > dquat
Definition arithmetic_types.hpp:48
mat< N, N, T > mat_sqr
Definition arithmetic_types.hpp:110
quat< int > iquat
Definition arithmetic_types.hpp:50
quat< bool > bquat
Definition arithmetic_types.hpp:52
quat< long double > ldquat
Definition arithmetic_types.hpp:49
quat< long long > llquat
Definition arithmetic_types.hpp:58
quat< signed char > scquat
Definition arithmetic_types.hpp:55
quat< unsigned int > uquat
Definition arithmetic_types.hpp:51
quat< unsigned char > ucquat
Definition arithmetic_types.hpp:54
quat< char > cquat
Definition arithmetic_types.hpp:53