FastLED
3.9.15
Loading...
Searching...
No Matches
type_traits.cpp.hpp
Go to the documentation of this file.
1
2
#include "
fl/stl/type_traits.h
"
3
#include "
fl/stl/int.h
"
4
#include "
fl/stl/compiler_control.h
"
5
#include "
fl/stl/static_assert.h
"
6
7
FL_DISABLE_WARNING_PUSH
8
FL_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
15
namespace
{
16
FL_MAYBE_UNUSED
void
__compile_test() {
17
FL_STATIC_ASSERT
(
fl::is_integral<int>::value
,
"int should be integral"
);
18
FL_STATIC_ASSERT
(
fl::is_integral<float>::value
==
false
,
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"
);
22
FL_STATIC_ASSERT
(
fl::is_integral<unsigned char>::value
,
23
"unsigned char should be integral"
);
24
FL_STATIC_ASSERT
(
fl::is_integral<signed char>::value
,
25
"signed char should be integral"
);
26
FL_STATIC_ASSERT
(
fl::is_integral<short>::value
,
"short should be integral"
);
27
FL_STATIC_ASSERT
(
fl::is_integral<unsigned short>::value
,
28
"unsigned short should be integral"
);
29
FL_STATIC_ASSERT
(
fl::is_integral<long>::value
,
"long should be integral"
);
30
FL_STATIC_ASSERT
(
fl::is_integral<unsigned long>::value
,
31
"unsigned long should be integral"
);
32
FL_STATIC_ASSERT
(
fl::is_integral<long long>::value
,
33
"long long should be integral"
);
34
FL_STATIC_ASSERT
(
fl::is_integral<unsigned long long>::value
,
35
"unsigned long long should be integral"
);
36
FL_STATIC_ASSERT
(
fl::is_integral<int *>::value
==
false
,
37
"int* should not be integral"
);
38
FL_STATIC_ASSERT
(
fl::is_integral<float *>::value
==
false
,
39
"float* should not be integral"
);
40
FL_STATIC_ASSERT
(
fl::is_integral<void>::value
==
false
,
41
"void should not be integral"
);
42
FL_STATIC_ASSERT
(
fl::is_integral<void *>::value
==
false
,
43
"void* should not be integral"
);
44
FL_STATIC_ASSERT
(
fl::is_integral<const int>::value
,
45
"const int should be integral"
);
46
FL_STATIC_ASSERT
(
fl::is_integral<const float>::value
==
false
,
47
"const float should not be integral"
);
48
FL_STATIC_ASSERT
(
fl::is_integral<const char>::value
,
49
"const char should be integral"
);
50
FL_STATIC_ASSERT
(
fl::is_integral<const unsigned char>::value
,
51
"const unsigned char should be integral"
);
52
FL_STATIC_ASSERT
(
fl::is_integral<const signed char>::value
,
53
"const signed char should be integral"
);
54
FL_STATIC_ASSERT
(
fl::is_integral<const short>::value
,
55
"const short should be integral"
);
56
FL_STATIC_ASSERT
(
fl::is_integral<const unsigned short>::value
,
57
"const unsigned short should be integral"
);
58
FL_STATIC_ASSERT
(
fl::is_integral<const long>::value
,
59
"const long should be integral"
);
60
FL_STATIC_ASSERT
(
fl::is_integral<const unsigned long>::value
,
61
"const unsigned long should be integral"
);
62
FL_STATIC_ASSERT
(
fl::is_integral<const long long>::value
,
63
"const long long should be integral"
);
64
FL_STATIC_ASSERT
(
fl::is_integral<const unsigned long long>::value
,
65
"const unsigned long long should be integral"
);
66
67
// volatile
68
FL_STATIC_ASSERT
(
fl::is_integral<volatile int>::value
,
69
"volatile int should be integral"
);
70
FL_STATIC_ASSERT
(
fl::is_integral<volatile float>::value
==
false
,
71
"volatile float should not be integral"
);
72
FL_STATIC_ASSERT
(
fl::is_integral<volatile char>::value
,
73
"volatile char should be integral"
);
74
75
// ref
76
FL_STATIC_ASSERT
(
fl::is_integral<unsigned char &>::value
,
77
"unsigned char& should be integral"
);
78
FL_STATIC_ASSERT
(
fl::is_integral<const unsigned char &>::value
,
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"
);
83
FL_STATIC_ASSERT
(
fl::is_integral<fl::u8>::value
,
84
"u8 should be integral"
);
85
FL_STATIC_ASSERT
(
fl::is_integral<fl::i16>::value
,
86
"i16 should be integral"
);
87
FL_STATIC_ASSERT
(
fl::is_integral<fl::u16>::value
,
88
"u16 should be integral"
);
89
FL_STATIC_ASSERT
(
fl::is_integral<fl::i32>::value
,
90
"i32 should be integral"
);
91
FL_STATIC_ASSERT
(
fl::is_integral<fl::u32>::value
,
92
"u32 should be integral"
);
93
FL_STATIC_ASSERT
(
fl::is_integral<fl::i64>::value
,
94
"fl::i64 should be integral"
);
95
FL_STATIC_ASSERT
(
fl::is_integral<fl::u64>::value
,
96
"fl::u64 should be integral"
);
97
FL_STATIC_ASSERT
(
fl::is_integral<fl::i8 *>::value
==
false
,
98
"i8* should not be integral"
);
99
FL_STATIC_ASSERT
(
fl::is_integral<fl::u8 *>::value
==
false
,
100
"u8* should not be integral"
);
101
FL_STATIC_ASSERT
(
fl::is_integral<fl::uint>::value
,
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"
);
106
FL_STATIC_ASSERT
(
fl::is_integral<fl::u8>::value
,
107
"fl::u8 should be integral"
);
108
FL_STATIC_ASSERT
(
fl::is_integral<fl::i16>::value
,
109
"fl::i16 should be integral"
);
110
FL_STATIC_ASSERT
(
fl::is_integral<fl::u16>::value
,
111
"fl::u16 should be integral"
);
112
FL_STATIC_ASSERT
(
fl::is_integral<fl::i32>::value
,
113
"fl::i32 should be integral"
);
114
FL_STATIC_ASSERT
(
fl::is_integral<fl::u32>::value
,
115
"fl::u32 should be integral"
);
116
FL_STATIC_ASSERT
(
fl::is_integral<i64>::value
,
117
"i64 should be integral"
);
118
FL_STATIC_ASSERT
(
fl::is_integral<u64>::value
,
119
"u64 should be integral"
);
120
FL_STATIC_ASSERT
(
fl::is_integral<fl::i8 *>::value
==
false
,
121
"fl::i8* should not be integral"
);
122
FL_STATIC_ASSERT
(
fl::is_integral<fl::u8 *>::value
==
false
,
123
"fl::u8* should not be integral"
);
124
}
125
}
// namespace
126
127
FL_DISABLE_WARNING_POP
compiler_control.h
int.h
FL_DISABLE_WARNING
#define FL_DISABLE_WARNING(warning)
FL_STATIC_ASSERT
#define FL_STATIC_ASSERT(...)
FL_DISABLE_WARNING_PUSH
#define FL_DISABLE_WARNING_PUSH
FL_DISABLE_WARNING_POP
#define FL_DISABLE_WARNING_POP
FL_MAYBE_UNUSED
#define FL_MAYBE_UNUSED
static_assert.h
Portable compile-time assertion wrapper.
fl::is_integral::value
@ value
Definition
type_traits.h:414
type_traits.h
fl
stl
type_traits.cpp.hpp
Generated on Tue Jun 16 2026 00:07:00 for FastLED by
1.13.2