xcal
基于 C++23 的现代图形渲染引擎
载入中...
搜索中...
未找到
declaration.hpp
浏览该文件的文档.
1
8#pragma once
9#ifndef XCMATH_DECLARATION_HPP
10#define XCMATH_DECLARATION_HPP
11
12#include <cstddef>
13#include <type_traits>
14
15namespace xcmath {
16
22template <size_t... _idx>
23struct Slice {
24 static constexpr size_t length =
25 sizeof...(_idx);
26};
27
28template <size_t _From, size_t _To, size_t _Step = 1>
29constexpr auto slice_from_to = []() {
30 if constexpr (_From <= _To)
31 return [&]<size_t... _Pack>(this auto&& self) {
32 if constexpr (_Step * sizeof...(_Pack) < _To - _From + 1)
33 return self.template
34 operator()<_Pack..., _From + _Step * sizeof...(_Pack)>();
35 else
36 return Slice<_Pack...>();
37 }();
38 else
39 return [&]<size_t... _Pack>(this auto&& self) {
40 if constexpr (_Step * sizeof...(_Pack) < _From - _To + 1)
41 return self.template
42 operator()<_Pack..., _From - _Step * sizeof...(_Pack)>();
43 else
44 return Slice<_Pack...>();
45 }();
46}();
47template <size_t _Start, size_t _Len, size_t _Step = 1>
48constexpr auto slice_start_len =
49 slice_from_to<_Start, _Start + (_Step * _Len) - 1, _Step>;
50template <size_t _Len, size_t _Step = 1>
51constexpr auto slice_to = slice_from_to<0, (_Step * _Len) - 1, _Step>;
52template <size_t _End, size_t _Len, size_t _Step = 1>
53constexpr auto slice_from_end =
54 slice_from_to<_End - (_Len * _Step) + 1, _End, _Step>;
55
62template <typename _Tp, size_t _length>
63 requires(_length > 0 && std::is_default_constructible_v<_Tp>)
64class vec;
65
73template <typename _Tp, size_t _rows, size_t _cols>
74class mat;
75
81template <typename T>
82class quaternion;
83
89template <typename T>
90class complex;
91
99template <class _Tp1, class... _Tp>
100vec(const _Tp1&, const _Tp...) -> vec<_Tp1, sizeof...(_Tp) + 1>;
101
102// vector type aliases
108template <typename T>
110
116template <typename T>
118
124template <typename T>
126
132template <size_t _len>
134
140template <size_t _len>
142
148template <size_t _len>
150
156template <size_t _len>
158
164template <size_t _len>
166
172template <size_t _len>
174
180template <size_t _len>
182
188template <size_t _len>
190
196template <size_t _len>
198
199// specific vector type aliases
227
228// matrix type aliases
234template <class _Tp>
236
242template <class _Tp>
244
250template <class _Tp>
252
258template <class _Tp>
260
266template <class _Tp>
268
274template <class _Tp>
276
282template <class _Tp>
284
290template <class _Tp>
292
298template <class _Tp>
300
306template <class _Tp>
308
314template <class _Tp>
316
322template <class _Tp>
324
330template <class _Tp>
332
338template <class _Tp>
340
346template <class _Tp>
348
354template <class _Tp>
356
362template <class _Tp>
364
365// specific matrix type aliases
381
397
413
429
445
461
480
481// constants
485constexpr long double PI =
486 3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679;
487
488} // namespace xcmath
489
490#endif // XCMATH_DECLARATION_HPP
Complex number class template
Definition complex.hpp:15
Matrix class template
Definition mat.hpp:27
Quaternion class template
Vector class template
Definition vec.hpp:206
Compiler-specific type information handling for MSVC
Definition complex.hpp:12
mat4x4< long > mat4x4l
constexpr long double PI
Pi constant
constexpr auto slice_from_end
mat3x3< unsigned long > mat3x3ul
mat2x2< long > mat2x2l
mat3x3< long > mat3x3l
mat4x4< double > mat4x4d
mat2x2< unsigned long > mat2x2ul
mat4x4< bool > mat4x4b
constexpr auto slice_from_to
mat3x3< int > mat3x3i
mat3x3< float > mat3x3f
mat4x4< int > mat4x4i
mat2x2< bool > mat2x2b
mat2x2< float > mat2x2f
mat3x3< double > mat3x3d
mat4x4< float > mat4x4f
mat4x4< unsigned long > mat4x4ul
mat2x2< double > mat2x2d
constexpr auto slice_to
constexpr auto slice_start_len
mat2x2< int > mat2x2i
mat3x3< bool > mat3x3b
Compile-time index sequence for vector slicing operations
static constexpr size_t length
Number of elements in slice