FastLED 3.9.15
Loading...
Searching...
No Matches
type_traits.cpp
Go to the documentation of this file.
1
2#include "fl/type_traits.h"
3#include "fl/int.h"
4
5#pragma GCC diagnostic push
6#pragma GCC diagnostic ignored "-Wunused-function"
7
8// Type traits are tricky and can be compiler dependent. We can't rely on
9// unit testing since that runs on the host machine. So to any type trait
10// that can statically be tested, add below.
11
12// typetrait test
13namespace {
15 static_assert(fl::is_integral<int>::value, "int should be integral");
16 static_assert(fl::is_integral<float>::value == false,
17 "float should not be integral");
18 static_assert(fl::is_integral<bool>::value, "bool should be integral");
19 static_assert(fl::is_integral<char>::value, "char should be integral");
21 "unsigned char should be integral");
23 "signed char should be integral");
24 static_assert(fl::is_integral<short>::value, "short should be integral");
26 "unsigned short should be integral");
27 static_assert(fl::is_integral<long>::value, "long should be integral");
29 "unsigned long should be integral");
31 "long long should be integral");
33 "unsigned long long should be integral");
34 static_assert(fl::is_integral<int *>::value == false,
35 "int* should not be integral");
36 static_assert(fl::is_integral<float *>::value == false,
37 "float* should not be integral");
38 static_assert(fl::is_integral<void>::value == false,
39 "void should not be integral");
40 static_assert(fl::is_integral<void *>::value == false,
41 "void* should not be integral");
43 "const int should be integral");
44 static_assert(fl::is_integral<const float>::value == false,
45 "const float should not be integral");
47 "const char should be integral");
49 "const unsigned char should be integral");
51 "const signed char should be integral");
53 "const short should be integral");
55 "const unsigned short should be integral");
57 "const long should be integral");
59 "const unsigned long should be integral");
61 "const long long should be integral");
63 "const unsigned long long should be integral");
64
65 // volatile
67 "volatile int should be integral");
68 static_assert(fl::is_integral<volatile float>::value == false,
69 "volatile float should not be integral");
71 "volatile char should be integral");
72
73 // ref
75 "unsigned char& should be integral");
77 "const unsigned char& should be integral");
78
79 // fixed width int types from fl/int.h
80 static_assert(fl::is_integral<fl::i8>::value, "i8 should be integral");
82 "u8 should be integral");
84 "i16 should be integral");
86 "u16 should be integral");
88 "i32 should be integral");
90 "u32 should be integral");
92 "fl::i64 should be integral");
94 "fl::u64 should be integral");
95 static_assert(fl::is_integral<fl::i8 *>::value == false,
96 "i8* should not be integral");
97 static_assert(fl::is_integral<fl::u8 *>::value == false,
98 "u8* should not be integral");
100 "uint should be integral");
101
102 // fixed width int types from fl/stdint.h
103 static_assert(fl::is_integral<int8_t>::value, "int8_t should be integral");
105 "uint8_t should be integral");
107 "int16_t should be integral");
109 "uint16_t should be integral");
111 "int32_t should be integral");
113 "uint32_t should be integral");
115 "int64_t should be integral");
117 "uint64_t should be integral");
118 static_assert(fl::is_integral<int8_t *>::value == false,
119 "int8_t* should not be integral");
120 static_assert(fl::is_integral<uint8_t *>::value == false,
121 "uint8_t* should not be integral");
122}
123} // namespace
124
125#pragma GCC diagnostic pop
static constexpr bool value