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 already defined
35 #if !defined(ETL_USING_BUILTIN_IS_ASSIGNABLE)
36 #define ETL_USING_BUILTIN_IS_ASSIGNABLE 1
37 #endif
38
39 #if !defined(ETL_USING_BUILTIN_IS_CONSTRUCTIBLE)
40 #define ETL_USING_BUILTIN_IS_CONSTRUCTIBLE 1
41 #endif
42
43 #if !defined(ETL_USING_BUILTIN_IS_TRIVIALLY_CONSTRUCTIBLE)
44 #define ETL_USING_BUILTIN_IS_TRIVIALLY_CONSTRUCTIBLE 1
45 #endif
46
47 #if !defined(ETL_USING_BUILTIN_IS_TRIVIALLY_DESTRUCTIBLE)
48 #define ETL_USING_BUILTIN_IS_TRIVIALLY_DESTRUCTIBLE 1
49 #endif
50
51 #if !defined(ETL_USING_BUILTIN_IS_TRIVIALLY_COPYABLE)
52 #define ETL_USING_BUILTIN_IS_TRIVIALLY_COPYABLE 1
53 #endif
54#endif
55
56#if defined(__has_builtin) // Use __has_builtin to check for existence of builtin functions?
57 #if !defined(ETL_USING_BUILTIN_IS_ASSIGNABLE)
58 #define ETL_USING_BUILTIN_IS_ASSIGNABLE __has_builtin(__is_assignable)
59 #endif
60
61 #if !defined(ETL_USING_BUILTIN_IS_CONSTRUCTIBLE)
62 #define ETL_USING_BUILTIN_IS_CONSTRUCTIBLE __has_builtin(__is_constructible)
63 #endif
64
65 #if !defined(ETL_USING_BUILTIN_IS_TRIVIALLY_CONSTRUCTIBLE)
66 #define ETL_USING_BUILTIN_IS_TRIVIALLY_CONSTRUCTIBLE (__has_builtin(__has_trivial_constructor) || __has_builtin(__is_trivially_constructible))
67 #endif
68
69 #if !defined(ETL_USING_BUILTIN_IS_TRIVIALLY_DESTRUCTIBLE)
70 #define ETL_USING_BUILTIN_IS_TRIVIALLY_DESTRUCTIBLE (__has_builtin(__has_trivial_destructor) || __has_builtin(__is_trivially_destructible))
71 #endif
72
73 #if !defined(ETL_USING_BUILTIN_IS_TRIVIALLY_COPYABLE)
74 #define ETL_USING_BUILTIN_IS_TRIVIALLY_COPYABLE (__has_builtin(__has_trivial_copy) || __has_builtin(__is_trivially_copyable))
75 #endif
76#endif
77
78// The default. Set to 0, if not already set.
79#if !defined(ETL_USING_BUILTIN_IS_ASSIGNABLE)
80 #define ETL_USING_BUILTIN_IS_ASSIGNABLE 0
81#endif
82
83#if !defined(ETL_USING_BUILTIN_IS_CONSTRUCTIBLE)
84 #define ETL_USING_BUILTIN_IS_CONSTRUCTIBLE 0
85#endif
86
87#if !defined(ETL_USING_BUILTIN_IS_TRIVIALLY_CONSTRUCTIBLE)
88 #define ETL_USING_BUILTIN_IS_TRIVIALLY_CONSTRUCTIBLE 0
89#endif
90
91#if !defined(ETL_USING_BUILTIN_IS_TRIVIALLY_DESTRUCTIBLE)
92 #define ETL_USING_BUILTIN_IS_TRIVIALLY_DESTRUCTIBLE 0
93#endif
94
95#if !defined(ETL_USING_BUILTIN_IS_TRIVIALLY_COPYABLE)
96 #define ETL_USING_BUILTIN_IS_TRIVIALLY_COPYABLE 0
97#endif
98
99namespace etl
100{
101 namespace traits
102 {
103 // Documentation: https://www.etlcpp.com/etl_traits.html
104
105 static ETL_CONSTANT bool using_builtin_is_assignable = (ETL_USING_BUILTIN_IS_ASSIGNABLE == 1);
106 static ETL_CONSTANT bool using_builtin_is_constructible = (ETL_USING_BUILTIN_IS_CONSTRUCTIBLE == 1);
107 static ETL_CONSTANT bool using_builtin_is_trivially_constructible = (ETL_USING_BUILTIN_IS_TRIVIALLY_CONSTRUCTIBLE == 1);
108 static ETL_CONSTANT bool using_builtin_is_trivially_destructible = (ETL_USING_BUILTIN_IS_TRIVIALLY_DESTRUCTIBLE == 1);
109 static ETL_CONSTANT bool using_builtin_is_trivially_copyable = (ETL_USING_BUILTIN_IS_TRIVIALLY_COPYABLE == 1);
110 }
111}
112
113#endif
bitset_ext
Definition absolute.h:38