FastLED
3.10.8
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
#include "
fl/stl/noexcept.h
"
7
8
FL_DISABLE_WARNING_PUSH
9
FL_DISABLE_WARNING
(unused-function)
10
11
// Type traits are tricky and can be compiler dependent. We can't rely on
12
// unit testing since that runs on the host machine. So to any type trait
13
// that can statically be tested, add below.
14
15
// typetrait test
16
namespace
{
17
FL_MAYBE_UNUSED
void
__compile_test()
FL_NO_EXCEPT
{
18
FL_STATIC_ASSERT
(
fl::is_integral<int>::value
,
"int should be integral"
);
19
FL_STATIC_ASSERT
(
fl::is_integral<float>::value
==
false
,
20
"float should not be integral"
);
21
FL_STATIC_ASSERT
(
fl::is_integral<bool>::value
,
"bool should be integral"
);
22
FL_STATIC_ASSERT
(
fl::is_integral<char>::value
,
"char should be integral"
);
23
FL_STATIC_ASSERT
(
fl::is_integral<unsigned char>::value
,
24
"unsigned char should be integral"
);
25
FL_STATIC_ASSERT
(
fl::is_integral<signed char>::value
,
26
"signed char should be integral"
);
27
FL_STATIC_ASSERT
(
fl::is_integral<short>::value
,
"short should be integral"
);
28
FL_STATIC_ASSERT
(
fl::is_integral<unsigned short>::value
,
29
"unsigned short should be integral"
);
30
FL_STATIC_ASSERT
(
fl::is_integral<long>::value
,
"long should be integral"
);
31
FL_STATIC_ASSERT
(
fl::is_integral<unsigned long>::value
,
32
"unsigned long should be integral"
);
33
FL_STATIC_ASSERT
(
fl::is_integral<long long>::value
,
34
"long long should be integral"
);
35
FL_STATIC_ASSERT
(
fl::is_integral<unsigned long long>::value
,
36
"unsigned long long should be integral"
);
37
FL_STATIC_ASSERT
(
fl::is_integral<int *>::value
==
false
,
38
"int* should not be integral"
);
39
FL_STATIC_ASSERT
(
fl::is_integral<float *>::value
==
false
,
40
"float* should not be integral"
);
41
FL_STATIC_ASSERT
(
fl::is_integral<void>::value
==
false
,
42
"void should not be integral"
);
43
FL_STATIC_ASSERT
(
fl::is_integral<void *>::value
==
false
,
44
"void* should not be integral"
);
45
FL_STATIC_ASSERT
(
fl::is_integral<const int>::value
,
46
"const int should be integral"
);
47
FL_STATIC_ASSERT
(
fl::is_integral<const float>::value
==
false
,
48
"const float should not be integral"
);
49
FL_STATIC_ASSERT
(
fl::is_integral<const char>::value
,
50
"const char should be integral"
);
51
FL_STATIC_ASSERT
(
fl::is_integral<const unsigned char>::value
,
52
"const unsigned char should be integral"
);
53
FL_STATIC_ASSERT
(
fl::is_integral<const signed char>::value
,
54
"const signed char should be integral"
);
55
FL_STATIC_ASSERT
(
fl::is_integral<const short>::value
,
56
"const short should be integral"
);
57
FL_STATIC_ASSERT
(
fl::is_integral<const unsigned short>::value
,
58
"const unsigned short should be integral"
);
59
FL_STATIC_ASSERT
(
fl::is_integral<const long>::value
,
60
"const long should be integral"
);
61
FL_STATIC_ASSERT
(
fl::is_integral<const unsigned long>::value
,
62
"const unsigned long should be integral"
);
63
FL_STATIC_ASSERT
(
fl::is_integral<const long long>::value
,
64
"const long long should be integral"
);
65
FL_STATIC_ASSERT
(
fl::is_integral<const unsigned long long>::value
,
66
"const unsigned long long should be integral"
);
67
68
// volatile
69
FL_STATIC_ASSERT
(
fl::is_integral<volatile int>::value
,
70
"volatile int should be integral"
);
71
FL_STATIC_ASSERT
(
fl::is_integral<volatile float>::value
==
false
,
72
"volatile float should not be integral"
);
73
FL_STATIC_ASSERT
(
fl::is_integral<volatile char>::value
,
74
"volatile char should be integral"
);
75
76
// ref
77
FL_STATIC_ASSERT
(
fl::is_integral<unsigned char &>::value
,
78
"unsigned char& should be integral"
);
79
FL_STATIC_ASSERT
(
fl::is_integral<const unsigned char &>::value
,
80
"const unsigned char& should be integral"
);
81
82
// fixed width int types from fl/int.h
83
FL_STATIC_ASSERT
(
fl::is_integral<fl::i8>::value
,
"i8 should be integral"
);
84
FL_STATIC_ASSERT
(
fl::is_integral<fl::u8>::value
,
85
"u8 should be integral"
);
86
FL_STATIC_ASSERT
(
fl::is_integral<fl::i16>::value
,
87
"i16 should be integral"
);
88
FL_STATIC_ASSERT
(
fl::is_integral<fl::u16>::value
,
89
"u16 should be integral"
);
90
FL_STATIC_ASSERT
(
fl::is_integral<fl::i32>::value
,
91
"i32 should be integral"
);
92
FL_STATIC_ASSERT
(
fl::is_integral<fl::u32>::value
,
93
"u32 should be integral"
);
94
FL_STATIC_ASSERT
(
fl::is_integral<fl::i64>::value
,
95
"fl::i64 should be integral"
);
96
FL_STATIC_ASSERT
(
fl::is_integral<fl::u64>::value
,
97
"fl::u64 should be integral"
);
98
FL_STATIC_ASSERT
(
fl::is_integral<fl::i8 *>::value
==
false
,
99
"i8* should not be integral"
);
100
FL_STATIC_ASSERT
(
fl::is_integral<fl::u8 *>::value
==
false
,
101
"u8* should not be integral"
);
102
FL_STATIC_ASSERT
(
fl::is_integral<fl::uint>::value
,
103
"uint should be integral"
);
104
105
// fixed width int types from fl/stl/stdint.h
106
FL_STATIC_ASSERT
(
fl::is_integral<fl::i8>::value
,
"fl::i8 should be integral"
);
107
FL_STATIC_ASSERT
(
fl::is_integral<fl::u8>::value
,
108
"fl::u8 should be integral"
);
109
FL_STATIC_ASSERT
(
fl::is_integral<fl::i16>::value
,
110
"fl::i16 should be integral"
);
111
FL_STATIC_ASSERT
(
fl::is_integral<fl::u16>::value
,
112
"fl::u16 should be integral"
);
113
FL_STATIC_ASSERT
(
fl::is_integral<fl::i32>::value
,
114
"fl::i32 should be integral"
);
115
FL_STATIC_ASSERT
(
fl::is_integral<fl::u32>::value
,
116
"fl::u32 should be integral"
);
117
FL_STATIC_ASSERT
(
fl::is_integral<i64>::value
,
118
"i64 should be integral"
);
119
FL_STATIC_ASSERT
(
fl::is_integral<u64>::value
,
120
"u64 should be integral"
);
121
FL_STATIC_ASSERT
(
fl::is_integral<fl::i8 *>::value
==
false
,
122
"fl::i8* should not be integral"
);
123
FL_STATIC_ASSERT
(
fl::is_integral<fl::u8 *>::value
==
false
,
124
"fl::u8* should not be integral"
);
125
}
126
}
// namespace
127
128
FL_DISABLE_WARNING_POP
FL_DISABLE_WARNING
#define FL_DISABLE_WARNING(warning)
Definition
compiler_control.h:25
FL_DISABLE_WARNING_PUSH
#define FL_DISABLE_WARNING_PUSH
Definition
compiler_control.h:23
FL_DISABLE_WARNING_POP
#define FL_DISABLE_WARNING_POP
Definition
compiler_control.h:24
FL_MAYBE_UNUSED
#define FL_MAYBE_UNUSED
Definition
compiler_control.h:317
compiler_control.h
int.h
noexcept.h
FL_NO_EXCEPT
#define FL_NO_EXCEPT
FL_STATIC_ASSERT
#define FL_STATIC_ASSERT(...)
Definition
static_assert.h:71
static_assert.h
Portable compile-time assertion wrapper.
fl::is_integral::value
@ value
Definition
type_traits.h:418
type_traits.h
fl
stl
type_traits.cpp.hpp
Generated on Sun Oct 18 2026 00:56:53 for FastLED by
1.13.2