FastLED 3.9.15
Loading...
Searching...
No Matches
type_traits.cpp.hpp
Go to the documentation of this file.
1
3#include "fl/stl/int.h"
6
8FL_DISABLE_WARNING(unused-function)
9
10// Type traits are tricky and can be compiler dependent. We can't rely on
11// unit testing since that runs on the host machine. So to any type trait
12// that can statically be tested, add below.
13
14// typetrait test
15namespace {
16FL_MAYBE_UNUSED void __compile_test() {
17 FL_STATIC_ASSERT(fl::is_integral<int>::value, "int should be integral");
19 "float should not be integral");
20 FL_STATIC_ASSERT(fl::is_integral<bool>::value, "bool should be integral");
21 FL_STATIC_ASSERT(fl::is_integral<char>::value, "char should be integral");
23 "unsigned char should be integral");
25 "signed char should be integral");
26 FL_STATIC_ASSERT(fl::is_integral<short>::value, "short should be integral");
28 "unsigned short should be integral");
29 FL_STATIC_ASSERT(fl::is_integral<long>::value, "long should be integral");
31 "unsigned long should be integral");
33 "long long should be integral");
35 "unsigned long long should be integral");
37 "int* should not be integral");
39 "float* should not be integral");
41 "void should not be integral");
43 "void* should not be integral");
45 "const int should be integral");
47 "const float should not be integral");
49 "const char should be integral");
51 "const unsigned char should be integral");
53 "const signed char should be integral");
55 "const short should be integral");
57 "const unsigned short should be integral");
59 "const long should be integral");
61 "const unsigned long should be integral");
63 "const long long should be integral");
65 "const unsigned long long should be integral");
66
67 // volatile
69 "volatile int should be integral");
71 "volatile float should not be integral");
73 "volatile char should be integral");
74
75 // ref
77 "unsigned char& should be integral");
79 "const unsigned char& should be integral");
80
81 // fixed width int types from fl/int.h
82 FL_STATIC_ASSERT(fl::is_integral<fl::i8>::value, "i8 should be integral");
84 "u8 should be integral");
86 "i16 should be integral");
88 "u16 should be integral");
90 "i32 should be integral");
92 "u32 should be integral");
94 "fl::i64 should be integral");
96 "fl::u64 should be integral");
98 "i8* should not be integral");
100 "u8* should not be integral");
102 "uint should be integral");
103
104 // fixed width int types from fl/stl/stdint.h
105 FL_STATIC_ASSERT(fl::is_integral<fl::i8>::value, "fl::i8 should be integral");
107 "fl::u8 should be integral");
109 "fl::i16 should be integral");
111 "fl::u16 should be integral");
113 "fl::i32 should be integral");
115 "fl::u32 should be integral");
117 "i64 should be integral");
119 "u64 should be integral");
121 "fl::i8* should not be integral");
123 "fl::u8* should not be integral");
124}
125} // namespace
126
#define FL_DISABLE_WARNING(warning)
#define FL_STATIC_ASSERT(...)
#define FL_DISABLE_WARNING_PUSH
#define FL_DISABLE_WARNING_POP
#define FL_MAYBE_UNUSED
Portable compile-time assertion wrapper.