Peano
Loading...
Searching...
No Matches
type.h
Go to the documentation of this file.
1#pragma once
2
3#include <cstdint>
4#include <optional>
5
6using i8 = std::int8_t;
7using u8 = std::uint8_t;
8using i16 = std::int16_t;
9using u16 = std::uint16_t;
10using i32 = std::int32_t;
11using u32 = std::uint32_t;
12using i64 = std::int64_t;
13using u64 = std::uint64_t;
14
15using f32 = float;
16using f64 = double;
17
18// https://stackoverflow.com/a/63454953/5769882
19struct Any {
20 template <typename T>
21 operator T&();
22
23 template <typename T>
24 operator T&&();
25};
26
27template<typename T> struct ptr {
28 using value = T*;
29};
30
32
33// https://stackoverflow.com/a/3221914/5769882
34#define STRCAT_INNER(a, b) a##b
35#define STRCAT(a, b) STRCAT_INNER(a, b)
36
37template<typename T>
38concept Dimensionality = requires(T t) {
39 { T::N } -> std::same_as<const u32 &>;
40};
41
42template<u32 dims>
43struct ND {
44 static const constexpr u32 N = dims;
45};
46
47using _1D = ND<1>;
48static_assert(Dimensionality<_1D>);
49
50using _2D = ND<2>;
51static_assert(Dimensionality<_2D>);
52
53using _3D = ND<3>;
54static_assert(Dimensionality<_3D>);
55
56template<typename T>
57concept Precision = std::floating_point<T>;
58
59template<typename T>
60concept NotVoid = !std::is_same_v<T, void>;
61
62template<typename T>
63concept Optional = std::same_as<T, std::optional<typename T::value_type>>;
64
65template<typename T, typename V>
66concept OptionalValue = std::same_as<V, std::optional<typename T::value_type>>;
Definition type.h:60
Definition type.h:19
Definition type.h:43
static const constexpr u32 N
Definition type.h:44
Definition type.h:27
T * value
Definition type.h:28
std::int8_t i8
Definition type.h:6
ptr< void >::value void_ptr
Definition type.h:31
std::uint8_t u8
Definition type.h:7
std::uint32_t u32
Definition type.h:11
std::uint64_t u64
Definition type.h:13
std::uint16_t u16
Definition type.h:9
std::int16_t i16
Definition type.h:8
double f64
Definition type.h:16
float f32
Definition type.h:15
std::int64_t i64
Definition type.h:12
std::int32_t i32
Definition type.h:10