Embedded Template Library 1.0
Loading...
Searching...
No Matches
determine_builtin_support.h
Go to the documentation of this file.
1
2
3/******************************************************************************
4The MIT License(MIT)
5
6Embedded Template Library.
7https://github.com/ETLCPP/etl
8https://www.etlcpp.com
9
10Copyright(c) 2021 John Wellbelove
11
12Permission is hereby granted, free of charge, to any person obtaining a copy
13of this software and associated documentation files(the "Software"), to deal
14in the Software without restriction, including without limitation the rights
15to use, copy, modify, merge, publish, distribute, sublicense, and / or sell
16copies of the Software, and to permit persons to whom the Software is
17furnished to do so, subject to the following conditions :
18
19The above copyright notice and this permission notice shall be included in all
20copies or substantial portions of the Software.
21
22THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
23IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
24FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE
25AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
26LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
27OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
28SOFTWARE.
29******************************************************************************/
30
31#ifndef ETL_DETERMINE_BUILTIN_SUPPORT_H_INCLUDED
32#define ETL_DETERMINE_BUILTIN_SUPPORT_H_INCLUDED
33
34#if defined(ETL_USE_TYPE_TRAITS_BUILTINS) // Set all of them to be true if not
35 // already defined
36 #if !defined(ETL_USING_BUILTIN_IS_ASSIGNABLE)
37 #define ETL_USING_BUILTIN_IS_ASSIGNABLE 1
38 #endif
39
40 #if !defined(ETL_USING_BUILTIN_IS_CONSTRUCTIBLE)
41 #define ETL_USING_BUILTIN_IS_CONSTRUCTIBLE 1
42 #endif
43
44 #if !defined(ETL_USING_BUILTIN_IS_TRIVIALLY_CONSTRUCTIBLE)
45 #define ETL_USING_BUILTIN_IS_TRIVIALLY_CONSTRUCTIBLE 1
46 #endif
47
48 #if !defined(ETL_USING_BUILTIN_IS_TRIVIALLY_DESTRUCTIBLE)
49 #define ETL_USING_BUILTIN_IS_TRIVIALLY_DESTRUCTIBLE 1
50 #endif
51
52 #if !defined(ETL_USING_BUILTIN_IS_TRIVIALLY_COPYABLE)
53 #define ETL_USING_BUILTIN_IS_TRIVIALLY_COPYABLE 1
54 #endif
55
56 #if !defined(ETL_USING_BUILTIN_UNDERLYING_TYPE)
57 #define ETL_USING_BUILTIN_UNDERLYING_TYPE 1
58 #endif
59
60 #if !defined(ETL_USING_BUILTIN_IS_CONSTANT_EVALUATED)
61 #define ETL_USING_BUILTIN_IS_CONSTANT_EVALUATED 1
62 #endif
63
64 #if !defined(ETL_USING_BUILTIN_MEMCPY)
65 #define ETL_USING_BUILTIN_MEMCPY 1
66 #endif
67
68 #if !defined(ETL_USING_BUILTIN_MEMMOVE)
69 #define ETL_USING_BUILTIN_MEMMOVE 1
70 #endif
71
72 #if !defined(ETL_USING_BUILTIN_MEMSET)
73 #define ETL_USING_BUILTIN_MEMSET 1
74 #endif
75
76 #if !defined(ETL_USING_BUILTIN_MEMCMP)
77 #define ETL_USING_BUILTIN_MEMCMP 1
78 #endif
79
80 #if !defined(ETL_USING_BUILTIN_MEMCHR)
81 #define ETL_USING_BUILTIN_MEMCHR 1
82 #endif
83#endif
84
85#if defined(__has_builtin) && !defined(ETL_COMPILER_MICROSOFT) // Use __has_builtin to check for
86 // existence of builtin functions?
87 // Fix VS2022 intellisense issue.
88 #if !defined(ETL_USING_BUILTIN_IS_ASSIGNABLE)
89 #define ETL_USING_BUILTIN_IS_ASSIGNABLE __has_builtin(__is_assignable)
90 #endif
91
92 #if !defined(ETL_USING_BUILTIN_IS_CONSTRUCTIBLE)
93 #define ETL_USING_BUILTIN_IS_CONSTRUCTIBLE __has_builtin(__is_constructible)
94 #endif
95
96 #if !defined(ETL_USING_BUILTIN_IS_TRIVIALLY_CONSTRUCTIBLE)
97 #define ETL_USING_BUILTIN_IS_TRIVIALLY_CONSTRUCTIBLE (__has_builtin(__has_trivial_constructor) || __has_builtin(__is_trivially_constructible))
98 #endif
99
100 #if !defined(ETL_USING_BUILTIN_IS_TRIVIALLY_DESTRUCTIBLE)
101 #define ETL_USING_BUILTIN_IS_TRIVIALLY_DESTRUCTIBLE (__has_builtin(__has_trivial_destructor) || __has_builtin(__is_trivially_destructible))
102 #endif
103
104 #if !defined(ETL_USING_BUILTIN_IS_TRIVIALLY_COPYABLE)
105 #define ETL_USING_BUILTIN_IS_TRIVIALLY_COPYABLE (__has_builtin(__has_trivial_copy) || __has_builtin(__is_trivially_copyable))
106 #endif
107
108 #if !defined(ETL_USING_BUILTIN_UNDERLYING_TYPE)
109 #define ETL_USING_BUILTIN_UNDERLYING_TYPE __has_builtin(__underlying_type)
110 #endif
111
112 #if !defined(ETL_USING_BUILTIN_IS_CONSTANT_EVALUATED)
113 #define ETL_USING_BUILTIN_IS_CONSTANT_EVALUATED __has_builtin(__builtin_is_constant_evaluated)
114 #endif
115
116 #if !defined(ETL_USING_BUILTIN_MEMCPY)
117 #define ETL_USING_BUILTIN_MEMCPY __has_builtin(__builtin_memcpy)
118 #endif
119
120 #if !defined(ETL_USING_BUILTIN_MEMMOVE)
121 #define ETL_USING_BUILTIN_MEMMOVE __has_builtin(__builtin_memmove)
122 #endif
123
124 #if !defined(ETL_USING_BUILTIN_MEMSET)
125 #define ETL_USING_BUILTIN_MEMSET __has_builtin(__builtin_memset)
126 #endif
127
128 #if !defined(ETL_USING_BUILTIN_MEMCMP)
129 #define ETL_USING_BUILTIN_MEMCMP __has_builtin(__builtin_memcmp)
130 #endif
131
132 #if !defined(ETL_USING_BUILTIN_MEMCHR)
133 #define ETL_USING_BUILTIN_MEMCHR __has_builtin(__builtin_memchr)
134 #endif
135#endif
136
137// The default. Set to 0, if not already set.
138#if !defined(ETL_USING_BUILTIN_IS_ASSIGNABLE)
139 #define ETL_USING_BUILTIN_IS_ASSIGNABLE 0
140#endif
141
142#if !defined(ETL_USING_BUILTIN_IS_CONSTRUCTIBLE)
143 #define ETL_USING_BUILTIN_IS_CONSTRUCTIBLE 0
144#endif
145
146#if !defined(ETL_USING_BUILTIN_IS_TRIVIALLY_CONSTRUCTIBLE)
147 #define ETL_USING_BUILTIN_IS_TRIVIALLY_CONSTRUCTIBLE 0
148#endif
149
150#if !defined(ETL_USING_BUILTIN_IS_TRIVIALLY_DESTRUCTIBLE)
151 #define ETL_USING_BUILTIN_IS_TRIVIALLY_DESTRUCTIBLE 0
152#endif
153
154#if !defined(ETL_USING_BUILTIN_IS_TRIVIALLY_COPYABLE)
155 #define ETL_USING_BUILTIN_IS_TRIVIALLY_COPYABLE 0
156#endif
157
158#if !defined(ETL_USING_BUILTIN_UNDERLYING_TYPE)
159 #define ETL_USING_BUILTIN_UNDERLYING_TYPE 0
160#endif
161
162#if !defined(ETL_USING_BUILTIN_IS_CONSTANT_EVALUATED)
163 #define ETL_USING_BUILTIN_IS_CONSTANT_EVALUATED 0
164#endif
165
166#if !defined(ETL_USING_BUILTIN_MEMCPY)
167 #define ETL_USING_BUILTIN_MEMCPY 0
168#endif
169
170#if !defined(ETL_USING_BUILTIN_MEMMOVE)
171 #define ETL_USING_BUILTIN_MEMMOVE 0
172#endif
173
174#if !defined(ETL_USING_BUILTIN_MEMSET)
175 #define ETL_USING_BUILTIN_MEMSET 0
176#endif
177
178#if !defined(ETL_USING_BUILTIN_MEMCMP)
179 #define ETL_USING_BUILTIN_MEMCMP 0
180#endif
181
182#if !defined(ETL_USING_BUILTIN_MEMCHR)
183 #define ETL_USING_BUILTIN_MEMCHR 0
184#endif
185
186namespace etl
187{
188 namespace traits
189 {
190 // Documentation: https://www.etlcpp.com/etl_traits.html
191
192 static ETL_CONSTANT bool using_builtin_is_assignable = (ETL_USING_BUILTIN_IS_ASSIGNABLE == 1);
193 static ETL_CONSTANT bool using_builtin_is_constructible = (ETL_USING_BUILTIN_IS_CONSTRUCTIBLE == 1);
194 static ETL_CONSTANT bool using_builtin_is_trivially_constructible = (ETL_USING_BUILTIN_IS_TRIVIALLY_CONSTRUCTIBLE == 1);
195 static ETL_CONSTANT bool using_builtin_is_trivially_destructible = (ETL_USING_BUILTIN_IS_TRIVIALLY_DESTRUCTIBLE == 1);
196 static ETL_CONSTANT bool using_builtin_is_trivially_copyable = (ETL_USING_BUILTIN_IS_TRIVIALLY_COPYABLE == 1);
197 static ETL_CONSTANT bool using_builtin_underlying_type = (ETL_USING_BUILTIN_UNDERLYING_TYPE == 1);
198 static ETL_CONSTANT bool using_builtin_is_constant_evaluated = (ETL_USING_BUILTIN_IS_CONSTANT_EVALUATED == 1);
199 static ETL_CONSTANT bool using_builtin_memcpy = (ETL_USING_BUILTIN_MEMCPY == 1);
200 static ETL_CONSTANT bool using_builtin_memmove = (ETL_USING_BUILTIN_MEMMOVE == 1);
201 static ETL_CONSTANT bool using_builtin_memset = (ETL_USING_BUILTIN_MEMSET == 1);
202 static ETL_CONSTANT bool using_builtin_memcmp = (ETL_USING_BUILTIN_MEMCMP == 1);
203 static ETL_CONSTANT bool using_builtin_memchr = (ETL_USING_BUILTIN_MEMCHR == 1);
204 } // namespace traits
205} // namespace etl
206
207#endif
bitset_ext
Definition absolute.h:40