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
4#pragma GCC diagnostic push
5#pragma GCC diagnostic ignored "-Wunused-function"
6
7// Type traits are tricky and can be compiler dependent. We can't rely on
8// unit testing since that runs on the host machine. So to any type trait
9// that can statically be tested, add below.
10
11// typetrait test
12namespace {
14 static_assert(fl::is_integral<int>::value, "int should be integral");
15 static_assert(fl::is_integral<float>::value == false,
16 "float should not be integral");
17 static_assert(fl::is_integral<bool>::value, "bool should be integral");
18 static_assert(fl::is_integral<char>::value, "char should be integral");
20 "unsigned char should be integral");
22 "signed char should be integral");
23 static_assert(fl::is_integral<short>::value, "short should be integral");
25 "unsigned short should be integral");
26 static_assert(fl::is_integral<long>::value, "long should be integral");
28 "unsigned long should be integral");
30 "long long should be integral");
32 "unsigned long long should be integral");
33 static_assert(fl::is_integral<int *>::value == false,
34 "int* should not be integral");
35 static_assert(fl::is_integral<float *>::value == false,
36 "float* should not be integral");
37 static_assert(fl::is_integral<void>::value == false,
38 "void should not be integral");
39 static_assert(fl::is_integral<void *>::value == false,
40 "void* should not be integral");
42 "const int should be integral");
43 static_assert(fl::is_integral<const float>::value == false,
44 "const float should not be integral");
46 "const char should be integral");
48 "const unsigned char should be integral");
50 "const signed char should be integral");
52 "const short should be integral");
54 "const unsigned short should be integral");
56 "const long should be integral");
58 "const unsigned long should be integral");
60 "const long long should be integral");
62 "const unsigned long long should be integral");
63
64 // volatile
66 "volatile int should be integral");
67 static_assert(fl::is_integral<volatile float>::value == false,
68 "volatile float should not be integral");
70 "volatile char should be integral");
71
72 // ref
74 "unsigned char& should be integral");
76 "const unsigned char& should be integral");
77
78 // fixed width int types
79 static_assert(fl::is_integral<int8_t>::value, "int8_t should be integral");
81 "uint8_t should be integral");
83 "int16_t should be integral");
85 "uint16_t should be integral");
87 "int32_t should be integral");
89 "uint32_t should be integral");
91 "int64_t should be integral");
93 "uint64_t should be integral");
94 static_assert(fl::is_integral<int8_t *>::value == false,
95 "int8_t* should not be integral");
96 static_assert(fl::is_integral<uint8_t *>::value == false,
97 "uint8_t* should not be integral");
98}
99} // namespace
100
101#pragma GCC diagnostic pop
static constexpr bool value