Embedded Template Library 1.0
Loading...
Searching...
No Matches
type_traits_generator.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) 2014 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/*[[[cog
32import cog
33cog.outl("#if 0")
34]]]*/
35/*[[[end]]]*/
36#error THIS HEADER IS A GENERATOR. DO NOT INCLUDE.
37/*[[[cog
38import cog
39cog.outl("#endif")
40]]]*/
41/*[[[end]]]*/
42
43/*[[[cog
44import cog
45cog.outl("//***************************************************************************")
46cog.outl("// THIS FILE HAS BEEN AUTO GENERATED. DO NOT EDIT THIS FILE.")
47cog.outl("//***************************************************************************")
48]]]*/
49/*[[[end]]]*/
50
51//***************************************************************************
52// To generate to header file, run this at the command line.
53// Note: You will need Python and COG installed.
54//
55// cog -d -e -otypes.h -DHandlers=<n> types_generator.h
56// Where <n> is the number of types to support.
57//
58// e.g.
59// To generate handlers for up to 16 types...
60// cog -d -e -otype_traits.h -DIsOneOf=16 type_traits_generator.h
61//
62// See generate.bat
63//***************************************************************************
64
65#ifndef ETL_TYPE_TRAITS_INCLUDED
66#define ETL_TYPE_TRAITS_INCLUDED
67
68#include "platform.h"
69#include "nullptr.h"
70#include "static_assert.h"
71
72#include <stddef.h>
73#include <stdint.h>
74
79
80#if ETL_USING_STL && ETL_USING_CPP11
81 #include <type_traits>
82#endif
83
84namespace etl
85{
86#if ETL_USING_CPP11
87 template <typename...>
88 using void_t = void;
89#endif
90
91#if ETL_NOT_USING_STL || ETL_CPP11_NOT_SUPPORTED
92
93 //*****************************************************************************
94 // Traits are defined by the ETL
95 //*****************************************************************************
96
97 //***************************************************************************
99 template <typename T, T VALUE>
100 struct integral_constant
101 {
102 static const T value = VALUE;
103
104 typedef T value_type;
106
107 operator value_type() const
108 {
109 return value;
110 }
111 };
112
115 typedef integral_constant<bool, true> true_type;
116
117 template <typename T, T VALUE>
118 const T integral_constant<T, VALUE>::value;
119
120#if ETL_USING_CPP17
121 template <typename T, T VALUE>
122 inline constexpr T integral_constant_v = etl::integral_constant<T, VALUE>::value;
123#endif
124
125#if ETL_USING_CPP11
126 template <bool BValue>
128#else
129 template <bool BValue>
130 struct bool_constant : etl::integral_constant<bool, BValue> { };
131#endif
132
133#if ETL_USING_CPP17
134 template <bool BValue>
135 inline constexpr bool bool_constant_v = bool_constant<BValue>::value;
136#endif
137
138 //***************************************************************************
140 template <typename T>
141 struct negation : etl::bool_constant<!bool(T::value)>
142 {
143 };
144
145#if ETL_USING_CPP17
146 template <typename T>
147 inline constexpr bool negation_v = negation<T>::value;
148#endif
149
150 //***************************************************************************
152 template <typename T> struct remove_reference { typedef T type; };
153 template <typename T> struct remove_reference<T&> { typedef T type; };
154#if ETL_USING_CPP11
155 template <typename T> struct remove_reference<T&&> { typedef T type; };
156#endif
157
158#if ETL_USING_CPP11
159 template <typename T>
160 using remove_reference_t = typename remove_reference<T>::type;
161#endif
162
163 //***************************************************************************
165 template <typename T> struct remove_pointer { typedef T type; };
166 template <typename T> struct remove_pointer<T*> { typedef T type; };
167 template <typename T> struct remove_pointer<const T*> { typedef const T type; };
168 template <typename T> struct remove_pointer<volatile T*> { typedef volatile T type; };
169 template <typename T> struct remove_pointer<const volatile T*> { typedef const volatile T type; };
170 template <typename T> struct remove_pointer<T* const> { typedef T type; };
171 template <typename T> struct remove_pointer<const T* const> { typedef const T type; };
172 template <typename T> struct remove_pointer<volatile T* const> { typedef volatile T type; };
173 template <typename T> struct remove_pointer<const volatile T* const> { typedef const volatile T type; };
174
175#if ETL_USING_CPP11
176 template <typename T>
177 using remove_pointer_t = typename remove_pointer<T>::type;
178#endif
179
180 //***************************************************************************
182 template <typename T> struct add_pointer { typedef typename remove_reference<T>::type* type; };
183
184#if ETL_USING_CPP11
185 template <typename T>
186 using add_pointer_t = typename add_pointer<T>::type;
187#endif
188
189 //***************************************************************************
191 template <typename T> struct is_const : false_type {};
192 template <typename T> struct is_const<const T> : true_type {};
193 template <typename T> struct is_const<const volatile T> : true_type {};
194
195#if ETL_USING_CPP17
196 template <typename T>
197 inline constexpr bool is_const_v = is_const<T>::value;
198#endif
199
200 //***************************************************************************
202 template <typename T> struct remove_const { typedef T type; };
203 template <typename T> struct remove_const<const T> { typedef T type; };
204
205#if ETL_USING_CPP11
206 template <typename T>
207 using remove_const_t = typename remove_const<T>::type;
208#endif
209
210 //***************************************************************************
212 template <typename T> struct add_const { typedef const T type; };
213 template <typename T> struct add_const<const T> { typedef const T type; };
214
215#if ETL_USING_CPP11
216 template <typename T>
217 using add_const_t = typename add_const<T>::type;
218#endif
219
220 //***************************************************************************
222 template <typename T> struct is_volatile : false_type {};
223 template <typename T> struct is_volatile<volatile T> : true_type {};
224 template <typename T> struct is_volatile<const volatile T> : true_type {};
225
226#if ETL_USING_CPP17
227 template <typename T>
228 inline constexpr bool is_volatile_v = is_volatile<T>::value;
229#endif
230
231 //***************************************************************************
233 template <typename T> struct remove_volatile { typedef T type; };
234 template <typename T> struct remove_volatile<volatile T> { typedef T type; };
235
236#if ETL_USING_CPP11
237 template <typename T>
238 using remove_volatile_t = typename remove_volatile<T>::type;
239#endif
240
241 //***************************************************************************
243 template <typename T> struct add_volatile { typedef volatile T type; };
244 template <typename T> struct add_volatile<volatile T> { typedef volatile T type; };
245
246#if ETL_USING_CPP11
247 template <typename T>
248 using add_volatile_t = typename add_volatile<T>::type;
249#endif
250
251 //***************************************************************************
253 template <typename T> struct remove_cv
254 {
255 typedef typename remove_volatile<typename remove_const<T>::type>::type type;
256 };
257
258#if ETL_USING_CPP11
259 template <typename T>
260 using remove_cv_t = typename remove_cv<T>::type;
261#endif
262
263 //***************************************************************************
265 template <typename T> struct add_cv
266 {
267 typedef typename add_volatile<typename add_const<T>::type>::type type;
268 };
269
270#if ETL_USING_CPP11
271 template <typename T>
272 using add_cv_t = typename add_cv<T>::type;
273#endif
274
275 //***************************************************************************
277 template <typename T> struct remove_cvref
278 {
279 typedef typename remove_cv<typename remove_reference<T>::type>::type type;
280 };
281
282#if ETL_USING_CPP11
283 template <typename T>
284 using remove_cvref_t = typename remove_cvref<T>::type;
285#endif
286
287 //***************************************************************************
289 template <typename T> struct is_integral : false_type {};
290 template <> struct is_integral<bool> : true_type {};
291 template <> struct is_integral<char> : true_type {};
292 template <> struct is_integral<unsigned char> : true_type {};
293 template <> struct is_integral<signed char> : true_type {};
294 template <> struct is_integral<wchar_t> : true_type {};
295 template <> struct is_integral<short> : true_type {};
296 template <> struct is_integral<unsigned short> : true_type {};
297 template <> struct is_integral<int> : true_type {};
298 template <> struct is_integral<unsigned int> : true_type {};
299 template <> struct is_integral<long> : true_type {};
300 template <> struct is_integral<unsigned long> : true_type {};
301 template <> struct is_integral<long long> : true_type {};
302 template <> struct is_integral<unsigned long long> : true_type {};
303#if ETL_HAS_NATIVE_CHAR8_T
304 template <> struct is_integral<char8_t> : true_type {};
305#endif
306#if ETL_HAS_NATIVE_CHAR16_T
307 template <> struct is_integral<char16_t> : true_type {};
308#endif
309#if ETL_HAS_NATIVE_CHAR32_T
310 template <> struct is_integral<char32_t> : true_type {};
311#endif
312 template <typename T> struct is_integral<const T> : is_integral<T> {};
313 template <typename T> struct is_integral<volatile T> : is_integral<T> {};
314 template <typename T> struct is_integral<const volatile T> : is_integral<T> {};
315
316#if ETL_USING_CPP17
317 template <typename T>
318 inline constexpr bool is_integral_v = is_integral<T>::value;
319#endif
320
321 //***************************************************************************
323 template <typename T> struct is_signed : false_type {};
324 template <> struct is_signed<char> : etl::bool_constant<(char(255) < 0)> {};
325 template <> struct is_signed<wchar_t> : public etl::bool_constant<wchar_t(-1) < wchar_t(0)> {};
326 template <> struct is_signed<signed char> : true_type {};
327 template <> struct is_signed<short> : true_type {};
328 template <> struct is_signed<int> : true_type {};
329 template <> struct is_signed<long> : true_type {};
330 template <> struct is_signed<long long> : true_type {};
331 template <> struct is_signed<float> : true_type {};
332 template <> struct is_signed<double> : true_type {};
333 template <> struct is_signed<long double> : true_type {};
334#if ETL_HAS_NATIVE_CHAR8_T
335 template <> struct is_signed<char8_t> : true_type {};
336#endif
337#if ETL_HAS_NATIVE_CHAR16_T
338 template <> struct is_signed<char16_t> : true_type {};
339#endif
340#if ETL_HAS_NATIVE_CHAR32_T
341 template <> struct is_signed<char32_t> : true_type {};
342#endif
343 template <typename T> struct is_signed<const T> : is_signed<T> {};
344 template <typename T> struct is_signed<volatile T> : is_signed<T> {};
345 template <typename T> struct is_signed<const volatile T> : is_signed<T> {};
346
347#if ETL_USING_CPP17
348 template <typename T>
349 inline constexpr bool is_signed_v = is_signed<T>::value;
350#endif
351
352 //***************************************************************************
354 template <typename T> struct is_unsigned : false_type {};
355 template <> struct is_unsigned<bool> : true_type {};
356 template <> struct is_unsigned<char> : etl::bool_constant<(char(255) > 0)> {};
357 template <> struct is_unsigned<unsigned char> : true_type {};
358 template <> struct is_unsigned<wchar_t> : public etl::bool_constant<(wchar_t(-1) > wchar_t(0))> {};
359 template <> struct is_unsigned<unsigned short> : true_type {};
360 template <> struct is_unsigned<unsigned int> : true_type {};
361 template <> struct is_unsigned<unsigned long> : true_type {};
362 template <> struct is_unsigned<unsigned long long> : true_type {};
363 template <typename T> struct is_unsigned<const T> : is_unsigned<T> {};
364 template <typename T> struct is_unsigned<volatile T> : is_unsigned<T> {};
365 template <typename T> struct is_unsigned<const volatile T> : is_unsigned<T> {};
366
367#if ETL_USING_CPP17
368 template <typename T>
369 inline constexpr bool is_unsigned_v = is_unsigned<T>::value;
370#endif
371
372 //***************************************************************************
374 template <typename T> struct is_floating_point : false_type {};
375 template <> struct is_floating_point<float> : true_type {};
376 template <> struct is_floating_point<double> : true_type {};
377 template <> struct is_floating_point<long double> : true_type {};
378 template <typename T> struct is_floating_point<const T> : is_floating_point<T> {};
379 template <typename T> struct is_floating_point<volatile T> : is_floating_point<T> {};
380 template <typename T> struct is_floating_point<const volatile T> : is_floating_point<T> {};
381
382#if ETL_USING_CPP17
383 template <typename T>
384 inline constexpr bool is_floating_point_v = is_floating_point<T>::value;
385#endif
386
387 //***************************************************************************
389 template <typename T1, typename T2> struct is_same : public false_type {};
390 template <typename T> struct is_same<T, T> : public true_type {};
391
392#if ETL_USING_CPP17
393 template <typename T1, typename T2>
394 inline constexpr bool is_same_v = is_same<T1, T2>::value;
395#endif
396
397 //***************************************************************************
399 template<typename T> struct is_void : false_type {};
400 template<> struct is_void<void> : true_type {};
401
402#if ETL_USING_CPP17
403 template <typename T>
404 inline constexpr bool is_void_v = is_void<T>::value;
405#endif
406
407 //***************************************************************************
409 template<typename T> struct is_arithmetic : etl::bool_constant<is_integral<T>::value || is_floating_point<T>::value> {};
410
411#if ETL_USING_CPP17
412 template <typename T>
413 inline constexpr bool is_arithmetic_v = is_arithmetic<T>::value;
414#endif
415
416 //***************************************************************************
418 template <typename T> struct is_fundamental : etl::bool_constant<is_arithmetic<T>::value || is_void<T>::value> {};
419
420#if ETL_USING_CPP17
421 template <typename T>
422 inline constexpr bool is_fundamental_v = is_fundamental<T>::value;
423#endif
424
425 //***************************************************************************
427 template <typename T> struct is_compound : etl::bool_constant<!is_fundamental<T>::value> {};
428
429#if ETL_USING_CPP17
430 template <typename T>
431 inline constexpr bool is_compound_v = is_compound<T>::value;
432#endif
433
434 //***************************************************************************
436 template <typename T> struct is_array : false_type {};
437 template <typename T> struct is_array<T[]> : true_type {};
438 template <typename T, size_t Size> struct is_array<T[Size]> : true_type {};
439
440#if ETL_USING_CPP17
441 template <typename T>
442 inline constexpr bool is_array_v = is_array<T>::value;
443#endif
444
445 //***************************************************************************
447 template<typename T> struct is_pointer_helper : false_type {};
448 template<typename T> struct is_pointer_helper<T*> : true_type {};
449 template<typename T> struct is_pointer_helper<const T*> : is_pointer_helper<T*> {};
450 template<typename T> struct is_pointer_helper<volatile T*> : is_pointer_helper<T*> {};
451 template<typename T> struct is_pointer_helper<const volatile T*> : is_pointer_helper<T*> {};
452 template<typename T> struct is_pointer : is_pointer_helper<typename remove_cv<T>::type> {};
453
454#if ETL_USING_CPP17
455 template <typename T>
456 inline constexpr bool is_pointer_v = is_pointer<T>::value;
457#endif
458
459 //***************************************************************************
461 template<typename T> struct is_lvalue_reference_helper : false_type {};
462 template<typename T> struct is_lvalue_reference_helper<T&> : true_type {};
463 template<typename T> struct is_lvalue_reference : is_lvalue_reference_helper<typename remove_cv<T>::type> {};
464
465#if ETL_USING_CPP17
466 template <typename T>
467 inline constexpr bool is_lvalue_reference_v = etl::is_lvalue_reference<T>::value;
468#endif
469
470#if ETL_USING_CPP11
471 //***************************************************************************
473 template<typename T> struct is_rvalue_reference_helper : false_type {};
474 template<typename T> struct is_rvalue_reference_helper<T&&> : true_type {};
475 template<typename T> struct is_rvalue_reference : is_rvalue_reference_helper<typename remove_cv<T>::type> {};
476
477#if ETL_USING_CPP17
478 template <typename T>
479 inline constexpr bool is_rvalue_reference_v = etl::is_rvalue_reference<T>::value;
480#endif
481#endif
482
483 //***************************************************************************
485 // Either lvalue or rvalue (for CPP11)
486 template<typename T> struct is_reference : integral_constant<bool,
487 is_lvalue_reference<T>::value
488 #if ETL_USING_CPP11
489 || is_rvalue_reference<T>::value
490 #endif
491 >{};
492
493#if ETL_USING_CPP17
494 template <typename T>
495 inline constexpr bool is_reference_v = is_reference<T>::value;
496#endif
497
498 //***************************************************************************
501 template <typename T> struct is_pod : etl::bool_constant<etl::is_fundamental<T>::value || etl::is_pointer<T>::value> {};
502
503#if ETL_USING_CPP17
504 template <typename T>
505 inline constexpr bool is_pod_v = etl::is_pod<T>::value;
506#endif
507
508 //***************************************************************************
510 template <bool BValue, typename T, typename F> struct conditional { typedef T type; };
511 template <typename T, typename F> struct conditional<false, T, F> { typedef F type; };
512
513#if ETL_USING_CPP11
514 template <bool BValue, typename T, typename F>
515 using conditional_t = typename conditional<BValue, T, F>::type;
516#endif
517
518 //***************************************************************************
520 template <typename T> struct make_signed { typedef T type; };
521 template <> struct make_signed<char> { typedef signed char type; };
522 template <> struct make_signed<unsigned char> { typedef signed char type; };
523
524 template <> struct make_signed<wchar_t>
525 {
526 typedef etl::conditional<sizeof(wchar_t) == sizeof(int16_t),
527 int16_t,
528 etl::conditional<sizeof(wchar_t) == sizeof(int32_t),
529 int32_t,
530 void>::type>::type type;
531 };
532
533 template <> struct make_signed<unsigned short> { typedef short type; };
534 template <> struct make_signed<unsigned int> { typedef int type; };
535 template <> struct make_signed<unsigned long> { typedef long type; };
536 template <> struct make_signed<unsigned long long> { typedef long long type; };
537 template <typename T> struct make_signed<const T> : add_const<typename make_signed<T>::type> {};
538 template <typename T> struct make_signed<volatile T> : add_volatile<typename make_signed<T>::type> {};
539 template <typename T> struct make_signed<const volatile T> : add_const<typename add_volatile<typename make_signed<T>::type>::type> {};
540
541#if ETL_USING_CPP11
542 template <typename T>
543 using make_signed_t = typename make_signed<T>::type;
544#endif
545
546 //***************************************************************************
548 template <typename T> struct make_unsigned { typedef T type; };
549 template <> struct make_unsigned<char> { typedef unsigned char type; };
550 template <> struct make_unsigned<signed char> { typedef unsigned char type; };
551 template <> struct make_unsigned<short> { typedef unsigned short type; };
552
553 template <> struct make_unsigned<wchar_t>
554 {
555 typedef etl::conditional<sizeof(wchar_t) == sizeof(uint16_t),
556 uint16_t,
557 etl::conditional<sizeof(wchar_t) == sizeof(uint32_t),
558 uint32_t,
559 void>::type>::type type;
560 };
561
562 template <> struct make_unsigned<int> { typedef unsigned int type; };
563 template <> struct make_unsigned<long> { typedef unsigned long type; };
564 template <> struct make_unsigned<long long> { typedef unsigned long long type; };
565 template <typename T> struct make_unsigned<const T> : add_const<typename make_unsigned<T>::type> {};
566 template <typename T> struct make_unsigned<volatile T> : add_volatile<typename make_unsigned<T>::type> {};
567 template <typename T> struct make_unsigned<const volatile T> : add_const<typename add_volatile<typename make_unsigned<T>::type>::type> {};
568
569#if ETL_USING_CPP11
570 template <typename T>
571 using make_unsigned_t = typename make_unsigned<T>::type;
572#endif
573
574 //***************************************************************************
576 template <bool BValue, typename T = void> struct enable_if {};
577 template <typename T> struct enable_if<true, T> { typedef T type; };
578
579#if ETL_USING_CPP11
580 template <bool BValue, typename T = void>
581 using enable_if_t = typename enable_if<BValue, T>::type;
582#endif
583
584 //***************************************************************************
586 template <typename T, unsigned Size = 0U>
587 struct extent : integral_constant<size_t, 0U> {};
588
589 template <typename T>
590 struct extent<T[], 0> : integral_constant<size_t, 0U> {};
591
592 template <typename T, unsigned Size>
593 struct extent<T[], Size> : integral_constant<size_t, extent<T, Size - 1>::value> {};
594
595 template <typename T, unsigned Size>
596 struct extent<T[Size], 0> : integral_constant<size_t, Size> {};
597
598 template <typename T, unsigned I, unsigned Size>
599 struct extent<T[I], Size> : integral_constant<size_t, extent<T, Size - 1>::value> {};
600
601#if ETL_USING_CPP17
602 template <typename T, unsigned Size = 0U>
603 inline constexpr size_t extent_v = extent<T, Size>::value;
604#endif
605
606 //***************************************************************************
608 template <typename T> struct remove_extent { typedef T type; };
609 template <typename T> struct remove_extent<T[]> { typedef T type; };
610 template <typename T, size_t Size> struct remove_extent<T[Size]> { typedef T type; };
611
612#if ETL_USING_CPP11
613 template <typename T>
614 using remove_extent_t = typename remove_extent<T>::type;
615#endif
616
617 //***************************************************************************
619 template <typename T> struct remove_all_extents { typedef T type; };
620 template <typename T> struct remove_all_extents<T[]> { typedef typename remove_all_extents<T>::type type; };
621 template <typename T, size_t Size> struct remove_all_extents<T[Size]> { typedef typename remove_all_extents<T>::type type; };
622
623#if ETL_USING_CPP11
624 template <typename T>
625 using remove_all_extents_t = typename remove_all_extents<T>::type;
626#endif
627
628 //***************************************************************************
630 template <typename T>struct rank : integral_constant<size_t, 0> {};
631 template <typename T> struct rank<T[]> : public integral_constant<size_t, rank<T>::value + 1> {};
632 template <typename T, size_t Size> struct rank<T[Size]> : public integral_constant<size_t, rank<T>::value + 1> {};
633
634#if ETL_USING_CPP17
635 template <typename T>
636 inline constexpr size_t rank_v = rank<T>::value;
637#endif
638
639 //***************************************************************************
641 template <typename T>
642 struct decay
643 {
644 typedef typename etl::remove_reference<T>::type U;
645 typedef typename etl::conditional<etl::is_array<U>::value,
646 typename etl::remove_extent<U>::type*,
647 typename etl::remove_cv<U>::type>::type type;
648 };
649
650#if ETL_USING_CPP11
651 template <typename T>
652 using decay_t = typename decay<T>::type;
653#endif
654
655 //***************************************************************************
657 template<typename TBase,
658 typename TDerived,
659 const bool IsFundamental = (etl::is_fundamental<TBase>::value || etl::is_fundamental<TDerived>::value || etl::is_array<TDerived>::value)>
660 struct is_base_of
661 {
662 private:
663
664 static TBase* check(TBase*) { return (TBase*)0; }
665 static char check(...) { return 0; }
666
667 public:
668
669 static const bool value = (sizeof(check((TDerived*)0)) == sizeof(TBase*));
670 };
671
672 // For when TBase or TDerived is a fundamental type.
673 template<typename TBase, typename TDerived>
675 {
676 static const bool value = false;
677 };
678
679#if ETL_USING_CPP17
680 template <typename T1, typename T2>
681 inline constexpr bool is_base_of_v = is_base_of<T1, T2>::value;
682#endif
683
684 //***************************************************************************
686 namespace private_type_traits
687 {
688 template <typename T> char test(int T::*); // Match for classes.
689
690 struct dummy { char c[2]; };
691 template <typename T> dummy test(...); // Match for non-classes.
692 }
693
694 template <typename T>
695 struct is_class : etl::bool_constant<sizeof(private_type_traits::test<T>(0)) == 1U> {};
696
697#if ETL_USING_CPP17
698 template <typename T>
699 inline constexpr bool is_class_v = is_class<T>::value;
700#endif
701
702 //***************************************************************************
704 template <typename T> struct add_lvalue_reference { typedef T& type; };
705 template <typename T> struct add_lvalue_reference<T&> { typedef T& type; };
706 template <> struct add_lvalue_reference<void> { typedef void type; };
707 template <> struct add_lvalue_reference<const void> { typedef const void type; };
708 template <> struct add_lvalue_reference<volatile void> { typedef volatile void type; };
709 template <> struct add_lvalue_reference<const volatile void> { typedef const volatile void type; };
710
711#if ETL_USING_CPP11
712 template <typename T>
713 using add_lvalue_reference_t = typename etl::add_lvalue_reference<T>::type;
714#endif
715
716 //***************************************************************************
718#if ETL_USING_CPP11
719 template <typename T> struct add_rvalue_reference { using type = T && ; };
720 template <typename T> struct add_rvalue_reference<T&> { using type = T & ; };
721 template <> struct add_rvalue_reference<void> { using type = void; };
722 template <> struct add_rvalue_reference<const void> { using type = const void; };
723 template <> struct add_rvalue_reference<volatile void> { using type = volatile void; };
724 template <> struct add_rvalue_reference<const volatile void> { using type = const volatile void; };
725#endif
726
727#if ETL_USING_CPP11
728 template <typename T>
729 using add_rvalue_reference_t = typename etl::add_rvalue_reference<T>::type;
730#endif
731
732 //***************************************************************************
734#if ETL_USING_CPP11
735 template <typename T>
736 typename etl::add_rvalue_reference<T>::type declval() ETL_NOEXCEPT;
737#endif
738
739#if ETL_USING_CPP11
740 //***************************************************************************
744
745 namespace private_type_traits
746 {
747 // Base case
748 template <typename T, typename = int>
749 struct is_convertible_to_int
750 : false_type
751 {
752 };
753
754 // Selected if `static_cast<int>(declval<T>())` is a valid statement
755 // 2nd template argument of base case defaults to int to ensure that this partial specialization is always tried first
756 template <typename T>
757 struct is_convertible_to_int<T, decltype(static_cast<int>(declval<T>()))>
758 : true_type
759 {
760 };
761 }
762
763 template <typename T>
764 struct is_enum
769 {
770 };
771
772#if ETL_USING_CPP17
773 template <typename T>
774 inline constexpr bool is_enum_v = etl::is_enum<T>::value;
775#endif
776#else
777 namespace private_type_traits
778 {
779 // Helper to detect if a type is convertible to an integer
780 template <typename T>
781 struct is_convertible_to_int
782 {
783 static char test(int); // Match if T is convertible to int
784 static double test(...); // Fallback for other types
785
786 static const bool value = sizeof(test(static_cast<T>(0))) == sizeof(char);
787 };
788 }
789
790 // Implementation of is_enum
791 template <typename T>
792 struct is_enum
793 {
794 static const bool value = private_type_traits::is_convertible_to_int<T>::value &&
795 !is_class<T>::value &&
796 !is_arithmetic<T>::value &&
797 !is_reference<T>::value;
798 };
799#endif
800
801 //***************************************************************************
804#if ETL_USING_CPP11
805 namespace private_type_traits
806 {
807 template <typename>
808 using true_type_for = etl::true_type;
809
810 template <typename T>
811 auto returnable(int)->true_type_for<T()>;
812
813 template <typename>
814 auto returnable(...)->etl::false_type;
815
816 template <typename TFrom, typename TTo>
817 auto nonvoid_convertible(int)->true_type_for<decltype(etl::declval<void(&)(TTo)>()(etl::declval<TFrom>()))
818 >;
819 template <typename, typename>
820 auto nonvoid_convertible(...)->etl::false_type;
821 }
822
823#if defined(ETL_COMPILER_ARM5)
824 template <typename TFrom, typename TTo>
825 struct is_convertible : etl::bool_constant<__is_convertible_to(TFrom, TTo)> {};
826#else
827 template <typename TFrom, typename TTo>
828 struct is_convertible : etl::bool_constant<(decltype(private_type_traits::returnable<TTo>(0))::value &&
829 decltype(private_type_traits::nonvoid_convertible<TFrom, TTo>(0))::value) ||
830 (etl::is_void<TFrom>::value && etl::is_void<TTo>::value)> {};
831#endif
832
833 // Is convertible and the conversion is noexcept.
834 template <typename TFrom, typename TTo>
835 struct is_nothrow_convertible
836 {
837 private:
838 // Helper: a function taking TTo to require the conversion.
839 static void sink(TTo) noexcept;
840
841 // Selected only if 'sink(declval<TFrom>())' is a valid expression.
842 template <typename F>
843 static auto test(int) -> etl::bool_constant<noexcept(sink(etl::declval<F>()))>;
844
845 // Fallback if conversion is not viable.
846 template <typename>
847 static etl::false_type test(...);
848
849 public:
850 static ETL_CONSTANT bool value = decltype(test<TFrom>(0))::value;
851 };
852#endif
853
854#if ETL_USING_CPP17
855 template <typename TFrom, typename TTo >
856 inline constexpr bool is_convertible_v = etl::is_convertible<TFrom, TTo>::value;
857
858 template <typename TFrom, typename TTo >
859 inline constexpr bool is_nothrow_convertible_v = etl::is_nothrow_convertible<TFrom, TTo>::value;
860#endif
861
862 //***************************************************************************
865#if ETL_USING_CPP11 && !defined(ETL_COMPILER_ARM5)
866 template <typename T> struct alignment_of : integral_constant<size_t, alignof(T)> { };
867#elif defined(ETL_COMPILER_MICROSOFT)
868 template <typename T> struct alignment_of : integral_constant<size_t, size_t(__alignof(T))> {};
869#elif defined(ETL_COMPILER_IAR) || defined(ETL_COMPILER_TI)
870 template <typename T> struct alignment_of : integral_constant<size_t, size_t(__ALIGNOF__(T))> {};
871#else
872 template <typename T> struct alignment_of : integral_constant<size_t, size_t(__alignof__(T))> {};
873#endif
874
877 template <> struct alignment_of<void> : integral_constant <size_t, 0> {};
878 template <> struct alignment_of<const void> : integral_constant <size_t, 0> {};
879
880#if ETL_USING_CPP17
881 template <typename T>
882 inline constexpr size_t alignment_of_v = etl::alignment_of<T>::value;
883#endif
884
885#else // Condition = ETL_USING_STL && ETL_USING_CPP11
886
887//*****************************************************************************
888// Traits are derived from the STL
889//*****************************************************************************
890
891 //***************************************************************************
894 template <typename T, T VALUE>
895 struct integral_constant : std::integral_constant<T, VALUE> {};
896
900typedef integral_constant<bool, true> true_type;
901
902#if ETL_USING_CPP17
903 template <typename T, T VALUE>
904 inline constexpr T integral_constant_v = std::integral_constant<T, VALUE>::value;
905#endif
906
907#if ETL_USING_CPP17
908 template <bool BValue>
909 using bool_constant = std::bool_constant<BValue>;
910#else
911 template <bool BValue>
912 struct bool_constant : std::integral_constant<bool, BValue> { };
913#endif
914
915#if ETL_USING_CPP17
916 template <bool BValue>
917 inline constexpr bool bool_constant_v = bool_constant<BValue>::value;
918#endif
919
920 //***************************************************************************
923#if ETL_USING_CPP17
924 template <typename T>
925 using negation = std::negation<T>;
926#else
927 template <typename T>
928 struct negation : etl::bool_constant<!bool(T::value)>
929 {
930 };
931#endif
932
933#if ETL_USING_CPP17
934 template <typename T>
935 inline constexpr bool negation_v = std::negation_v<T>;
936#endif
937
938 //***************************************************************************
941 template <typename T> struct remove_reference : std::remove_reference<T> {};
942
943#if ETL_USING_CPP11
944 template <typename T>
945 using remove_reference_t = typename std::remove_reference<T>::type;
946#endif
947
948 //***************************************************************************
951 template <typename T> struct remove_pointer : std::remove_pointer<T> {};
952
953#if ETL_USING_CPP11
954 template <typename T>
955 using remove_pointer_t = typename std::remove_pointer<T>::type;
956#endif
957
958 //***************************************************************************
961 template <typename T> struct add_pointer : std::add_pointer<T> {};
962
963#if ETL_USING_CPP11
964 template <typename T>
965 using add_pointer_t = typename std::add_pointer<T>::type;
966#endif
967
968 //***************************************************************************
971 template <typename T> struct is_const : std::is_const<T> {};
972
973#if ETL_USING_CPP17
974 template <typename T>
975 inline constexpr bool is_const_v = std::is_const_v<T>;
976#endif
977
978 //***************************************************************************
981 template <typename T> struct remove_const : std::remove_const<T> {};
982
983#if ETL_USING_CPP11
984 template <typename T>
985 using remove_const_t = typename std::remove_const<T>::type;
986#endif
987
988 //***************************************************************************
991 template <typename T> struct add_const : std::add_const<T> {};
992
993#if ETL_USING_CPP11
994 template <typename T>
995 using add_const_t = typename std::add_const<T>::type;
996#endif
997
998 //***************************************************************************
1001 template <typename T> struct is_volatile : std::is_volatile<T> {};
1002
1003#if ETL_USING_CPP17
1004 template <typename T>
1005 inline constexpr bool is_volatile_v = std::is_volatile_v<T>;
1006#endif
1007
1008 //***************************************************************************
1011 template <typename T> struct remove_volatile : std::remove_volatile<T> {};
1012
1013#if ETL_USING_CPP11
1014 template <typename T>
1015 using remove_volatile_t = typename std::remove_volatile<T>::type;
1016#endif
1017
1018 //***************************************************************************
1021 template <typename T> struct add_volatile : std::add_volatile<T> {};
1022
1023#if ETL_USING_CPP11
1024 template <typename T>
1025 using add_volatile_t = typename std::add_volatile<T>::type;
1026#endif
1027
1028 //***************************************************************************
1031 template <typename T> struct remove_cv : std::remove_cv<T> {};
1032
1033#if ETL_USING_CPP11
1034 template <typename T>
1035 using remove_cv_t = typename std::remove_cv<T>::type;
1036#endif
1037
1038 //***************************************************************************
1041 template <typename T> struct add_cv : std::add_cv<T> {};
1042
1043#if ETL_USING_CPP11
1044 template <typename T>
1045 using add_cv_t = typename std::add_cv<T>::type;
1046#endif
1047
1048 //***************************************************************************
1051 template <typename T> struct remove_cvref
1052 {
1053 typedef typename std::remove_cv<typename std::remove_reference<T>::type>::type type;
1054 };
1055
1056#if ETL_USING_CPP11
1057 template <typename T>
1058 using remove_cvref_t = typename etl::remove_cvref<T>::type;
1059#endif
1060
1061 //***************************************************************************
1064 template <typename T> struct is_integral : std::is_integral<T> {};
1065
1066#if ETL_USING_CPP17
1067 template <typename T>
1068 inline constexpr bool is_integral_v = std::is_integral_v<T>;
1069#endif
1070
1071 //***************************************************************************
1074 template <typename T> struct is_signed : std::is_signed<T> {};
1075
1076#if ETL_USING_CPP17
1077 template <typename T>
1078 inline constexpr bool is_signed_v = std::is_signed_v<T>;
1079#endif
1080
1081 //***************************************************************************
1084 template <typename T> struct is_unsigned : std::is_unsigned<T> {};
1085
1086#if ETL_USING_CPP17
1087 template <typename T>
1088 inline constexpr bool is_unsigned_v = std::is_unsigned_v<T>;
1089#endif
1090
1091 //***************************************************************************
1094 template <typename T> struct is_floating_point : std::is_floating_point<T> {};
1095
1096#if ETL_USING_CPP17
1097 template <typename T>
1098 inline constexpr bool is_floating_point_v = std::is_floating_point_v<T>;
1099#endif
1100
1101 //***************************************************************************
1104 template <typename T1, typename T2> struct is_same : std::is_same<T1, T2> {};
1105
1106#if ETL_USING_CPP17
1107 template <typename T1, typename T2>
1108 inline constexpr bool is_same_v = std::is_same_v<T1, T2>;
1109#endif
1110
1111 //***************************************************************************
1114 template<typename T> struct is_void : std::is_void<T> {};
1115
1116#if ETL_USING_CPP17
1117 template <typename T>
1118 inline constexpr bool is_void_v = std::is_void_v<T>;
1119#endif
1120
1121 //***************************************************************************
1124 template<typename T> struct is_arithmetic : std::is_arithmetic<T> {};
1125
1126#if ETL_USING_CPP17
1127 template <typename T>
1128 inline constexpr bool is_arithmetic_v = std::is_arithmetic_v<T>;
1129#endif
1130
1131 //***************************************************************************
1134 template <typename T> struct is_fundamental : std::is_fundamental<T> {};
1135
1136#if ETL_USING_CPP17
1137 template <typename T>
1138 inline constexpr bool is_fundamental_v = std::is_fundamental_v<T>;
1139#endif
1140
1141 //***************************************************************************
1144 template <typename T> struct is_compound : std::is_compound<T> {};
1145
1146#if ETL_USING_CPP17
1147 template <typename T>
1148 inline constexpr bool is_compound_v = std::is_compound_v<T>;
1149#endif
1150
1151 //***************************************************************************
1154 template <typename T> struct is_array : std::is_array<T> {};
1155
1156#if ETL_USING_CPP17
1157 template <typename T>
1158 inline constexpr bool is_array_v = std::is_array_v<T>;
1159#endif
1160
1161 //***************************************************************************
1164 template<typename T> struct is_pointer : std::is_pointer<T> {};
1165
1166#if ETL_USING_CPP17
1167 template <typename T>
1168 inline constexpr bool is_pointer_v = std::is_pointer_v<T>;
1169#endif
1170
1171 //***************************************************************************
1174 template<typename T> struct is_reference : std::is_reference<T> {};
1175
1176#if ETL_USING_CPP17
1177 template <typename T>
1178 inline constexpr bool is_reference_v = std::is_reference_v<T>;
1179#endif
1180
1181 //***************************************************************************
1184 template<typename T> struct is_lvalue_reference : std::is_lvalue_reference<T> {};
1185
1186#if ETL_USING_CPP17
1187 template <typename T>
1188 inline constexpr bool is_lvalue_reference_v = std::is_lvalue_reference_v<T>;
1189#endif
1190
1191 //***************************************************************************
1194#if ETL_USING_CPP11
1195 template<typename T> struct is_rvalue_reference : std::is_rvalue_reference<T> {};
1196
1197#if ETL_USING_CPP17
1198 template <typename T>
1199 inline constexpr bool is_rvalue_reference_v = std::is_rvalue_reference_v<T>;
1200#endif
1201#endif
1202
1203 //***************************************************************************
1206 template <typename T>
1207 struct is_pod : std::integral_constant<bool, std::is_standard_layout<T>::value && std::is_trivial<T>::value> {};
1208
1209#if ETL_USING_CPP17
1210 template <typename T>
1211 inline constexpr bool is_pod_v = std::is_standard_layout_v<T> && std::is_trivial_v<T>;
1212#endif
1213
1214#if defined(ETL_COMPILER_GCC)
1215 #if ETL_COMPILER_VERSION >= 5
1216 #define ETL_GCC_V5_TYPE_TRAITS_SUPPORTED
1217 #endif
1218#endif
1219
1220 //***************************************************************************
1223 template <bool BValue, typename T, typename F> struct conditional { typedef T type; };
1224 template <typename T, typename F> struct conditional<false, T, F> { typedef F type; };
1225
1226#if ETL_USING_CPP11
1227 template <bool BValue, typename T, typename F>
1228 using conditional_t = typename conditional<BValue, T, F>::type;
1229#endif
1230
1231 //***************************************************************************
1234 template <typename T> struct make_signed : std::make_signed<T> {};
1235
1236#if ETL_USING_CPP11
1237 template <typename T>
1238 using make_signed_t = typename std::make_signed<T>::type;
1239#endif
1240
1241 //***************************************************************************
1244 template <typename T> struct make_unsigned : std::make_unsigned<T> {};
1245
1246#if ETL_USING_CPP11
1247 template <typename T>
1248 using make_unsigned_t = typename std::make_unsigned<T>::type;
1249#endif
1250
1251 //***************************************************************************
1254 template <bool BValue, typename T = void> struct enable_if : std::enable_if<BValue, T> {};
1255
1256#if ETL_USING_CPP11
1257 template <bool BValue, typename T = void>
1258 using enable_if_t = typename std::enable_if<BValue, T>::type;
1259#endif
1260
1261 //***************************************************************************
1264 template <typename T, unsigned Size = 0U>
1265 struct extent : std::extent<T, Size> {};
1266
1267#if ETL_USING_CPP17
1268 template <typename T, unsigned Size = 0U>
1269 inline constexpr size_t extent_v = std::extent_v<T, Size>;
1270#endif
1271
1272 //***************************************************************************
1275 template <typename T> struct remove_extent : std::remove_extent<T> { };
1276
1277#if ETL_USING_CPP11
1278 template <typename T>
1279 using remove_extent_t = typename std::remove_extent<T>::type;
1280#endif
1281
1282 //***************************************************************************
1285 template <typename T> struct remove_all_extents : std::remove_all_extents<T> { };
1286
1287#if ETL_USING_CPP11
1288 template <typename T>
1289 using remove_all_extents_t = typename std::remove_all_extents<T>::type;
1290#endif
1291
1292 //***************************************************************************
1295 template <typename T>struct rank : std::rank<T> {};
1296
1297#if ETL_USING_CPP17
1298 template <typename T>
1299 inline constexpr size_t rank_v = std::rank_v<T>;
1300#endif
1301
1302 //***************************************************************************
1305 template <typename T> struct decay : std::decay<T> {};
1306
1307#if ETL_USING_CPP11
1308 template <typename T>
1309 using decay_t = typename std::decay<T>::type;
1310#endif
1311
1312 //***************************************************************************
1315 template<typename TBase, typename TDerived> struct is_base_of : std::is_base_of<TBase, TDerived> {};
1316
1317#if ETL_USING_CPP17
1318 template <typename TBase, typename TDerived>
1319 inline constexpr bool is_base_of_v = std::is_base_of_v<TBase, TDerived>;
1320#endif
1321
1322 //***************************************************************************
1324 template <typename T> struct is_class : std::is_class<T>{};
1325
1326#if ETL_USING_CPP17
1327 template <typename T>
1328 inline constexpr bool is_class_v = is_class<T>::value;
1329#endif
1330
1331 //***************************************************************************
1333 template <typename T> struct add_lvalue_reference : std::add_lvalue_reference<T> {};
1334
1335#if ETL_USING_CPP11
1336 template <typename T>
1337 using add_lvalue_reference_t = typename std::add_lvalue_reference<T>::type;
1338#endif
1339
1340 //***************************************************************************
1342#if ETL_USING_CPP11
1343 template <typename T> struct add_rvalue_reference : std::add_rvalue_reference<T> {};
1344#endif
1345
1346#if ETL_USING_CPP11
1347 template <typename T>
1348 using add_rvalue_reference_t = typename std::add_rvalue_reference<T>::type;
1349#endif
1350
1351 //***************************************************************************
1353#if ETL_USING_CPP11
1354 template <typename T>
1355 typename std::add_rvalue_reference<T>::type declval() ETL_NOEXCEPT;
1356#endif
1357
1358#if ETL_USING_CPP11
1359 //***************************************************************************
1362 template <typename T>
1363 struct is_enum : std::is_enum<T>
1364 {
1365 };
1366
1367#if ETL_USING_CPP17
1368 template <typename T>
1369 inline constexpr bool is_enum_v = etl::is_enum<T>::value;
1370#endif
1371
1372#endif
1373
1374 //***************************************************************************
1377#if ETL_USING_CPP11
1378 template <typename TFrom, typename TTo>
1379 struct is_convertible : std::is_convertible<TFrom, TTo> {};
1380
1381 // Is convertible and the conversion is noexcept.
1382 template <typename TFrom, typename TTo>
1383 struct is_nothrow_convertible
1384 {
1385 private:
1386 // Helper: a function taking TTo to require the conversion.
1387 static void sink(TTo) noexcept;
1388
1389 // Selected only if 'sink(declval<TFrom>())' is a valid expression.
1390 template <typename F>
1391 static auto test(int) -> etl::bool_constant<noexcept(sink(etl::declval<F>()))>;
1392
1393 // Fallback if conversion is not viable.
1394 template <typename>
1395 static etl::false_type test(...);
1396
1397 public:
1398 static ETL_CONSTANT bool value = decltype(test<TFrom>(0))::value;
1399 };
1400#endif
1401
1402#if ETL_USING_CPP17
1403 template <typename TFrom, typename TTo>
1404 inline constexpr bool is_convertible_v = std::is_convertible_v<TFrom, TTo>;
1405
1406 template <typename TFrom, typename TTo >
1407 inline constexpr bool is_nothrow_convertible_v = is_nothrow_convertible<TFrom, TTo>::value;
1408#endif
1409
1410 //***************************************************************************
1413 template <typename T> struct alignment_of : std::alignment_of<T> {};
1414 template <> struct alignment_of<void> : std::integral_constant<size_t, 0> {};
1415 template <> struct alignment_of<const void> : std::integral_constant <size_t, 0> {};
1416
1417#if ETL_USING_CPP17
1418 template <typename T>
1419 inline constexpr size_t alignment_of_v = std::alignment_of_v<T>;
1420#endif
1421
1422#endif // Condition = ETL_USING_STL && ETL_USING_CPP11
1423
1424 //***************************************************************************
1425 // ETL extended type traits.
1426 //***************************************************************************
1427
1428#if ETL_USING_CPP11
1429 //***************************************************************************
1431#if ETL_USING_CPP11
1432 template <typename...>
1433 struct conjunction : public etl::true_type
1434 {
1435 };
1436
1437 template <typename T1, typename... Tn>
1438 struct conjunction<T1, Tn...> : public etl::conditional_t<bool(T1::value), etl::conjunction<Tn...>, T1>
1439 {
1440 };
1441
1442 template <typename T>
1443 struct conjunction<T> : public T
1444 {
1445 };
1446#endif
1447
1448#if ETL_USING_CPP17
1449 template <typename... T>
1450 inline constexpr bool conjunction_v = conjunction<T...>::value;
1451#endif
1452
1453 //***************************************************************************
1455#if ETL_USING_CPP11
1456 template <typename...>
1457 struct disjunction : public etl::false_type
1458 {
1459 };
1460
1461 template <typename T1, typename... Tn>
1462 struct disjunction<T1, Tn...> : public etl::conditional_t<bool(T1::value), T1, disjunction<Tn...>>
1463 {
1464 };
1465
1466 template <typename T1> struct disjunction<T1> : public T1
1467 {
1468 };
1469#endif
1470
1471#if ETL_USING_CPP17
1472 template <typename... T>
1473 inline constexpr bool disjunction_v = etl::disjunction<T...>::value;
1474#endif
1475
1476#endif
1477
1478 //***************************************************************************
1480#if ETL_USING_CPP11
1481 template <typename... TTypes>
1482 struct exclusive_disjunction;
1483
1484 template <typename T>
1485 struct exclusive_disjunction<T> : public etl::bool_constant<T::value>
1486 {
1487 };
1488
1489 // Recursive case: XOR the first two values and recurse
1490 template <typename T1, typename T2, typename... TRest>
1491 struct exclusive_disjunction<T1, T2, TRest...> : public etl::exclusive_disjunction<etl::integral_constant<bool, etl::disjunction<T1, T2>::value && !etl::conjunction<T1, T2>::value>, TRest...>
1492 {
1493 };
1494#endif
1495
1496#if ETL_USING_CPP17
1497 template <typename... T>
1498 inline constexpr bool exclusive_disjunction_v = etl::exclusive_disjunction<T...>::value;
1499#endif
1500
1501 //***************************************************************************
1503 // /\ingroup type_traits
1504 template <bool BValue, typename T, T TRUE_VALUE, T FALSE_VALUE>
1506
1507 template <typename T, T TRUE_VALUE, T FALSE_VALUE>
1508 struct conditional_integral_constant<true, T, TRUE_VALUE, FALSE_VALUE>
1509 {
1510 ETL_STATIC_ASSERT(etl::is_integral<T>::value, "Not an integral type");
1511 static const T value = TRUE_VALUE;
1512 };
1513
1514 template <typename T, T TRUE_VALUE, T FALSE_VALUE>
1515 struct conditional_integral_constant<false, T, TRUE_VALUE, FALSE_VALUE>
1516 {
1517 ETL_STATIC_ASSERT(etl::is_integral<T>::value, "Not an integral type");
1518 static const T value = FALSE_VALUE;
1519 };
1520
1521#if ETL_USING_CPP11
1522 //***************************************************************************
1525 template <typename T, typename... TRest>
1526 struct is_one_of : etl::disjunction<etl::is_same<T, TRest>...>
1527 {
1528 };
1529#else
1530 /*[[[cog
1531 import cog
1532 cog.outl("//***************************************************************************")
1533 cog.outl("/// Template to determine if a type is one of a specified list.")
1534 cog.outl("///\\ingroup types")
1535 cog.outl("template <typename T,")
1536 cog.out(" ")
1537 cog.out("typename T1, ")
1538 for n in range(2, int(IsOneOf)):
1539 cog.out("typename T%s = void, " % n)
1540 if n % 4 == 0:
1541 cog.outl("")
1542 cog.out(" ")
1543 cog.outl("typename T%s = void>" % IsOneOf)
1544 cog.outl("struct is_one_of")
1545 cog.outl("{")
1546 cog.outl(" static const bool value = ")
1547 for n in range(1, int(IsOneOf)):
1548 cog.outl(" etl::is_same<T, T%s>::value ||" % n)
1549 cog.outl(" etl::is_same<T, T%s>::value;" % IsOneOf)
1550 cog.outl("};")
1551 ]]]*/
1552 /*[[[end]]]*/
1553#endif
1554
1555#if ETL_USING_CPP17
1556 template <typename T, typename... TRest>
1557 inline constexpr bool is_one_of_v = etl::is_one_of<T, TRest...>::value;
1558#endif
1559
1560#if ETL_USING_CPP11
1561 namespace private_type_traits
1562 {
1563 //***************************************************************************
1564 // Helper to count occurrences of a type in a list of types
1565 template<typename T, typename... TTypes>
1566 struct count_type;
1567
1568 // Base case: zero occurrences
1569 template<typename T>
1570 struct count_type<T> : etl::integral_constant<size_t, 0>
1571 {
1572 };
1573
1574 // Recursive case: increment count if head is the same as T, otherwise continue with tail
1575 template<typename T, typename THead, typename... TTail>
1576 struct count_type<T, THead, TTail...> : etl::integral_constant<size_t, (etl::is_same<T, THead>::value ? 1 : 0) + count_type<T, TTail...>::value>
1577 {
1578 };
1579 }
1580
1581 template<typename T, typename... TTypes>
1582 struct has_duplicates_of
1583 : etl::integral_constant<bool, (private_type_traits::count_type<T, TTypes...>::value > 1)>
1584 {
1585 };
1586#endif
1587
1588#if ETL_USING_CPP17
1589 template <typename T, typename... TRest>
1590 inline constexpr bool has_duplicates_of_v = etl::has_duplicates_of<T, TRest...>::value;
1591#endif
1592
1593#if ETL_USING_CPP11
1594 //***************************************************************************
1597 template <typename TBase, typename... TDerived>
1598 struct is_base_of_all : etl::conjunction<etl::is_base_of<TBase, TDerived>...>
1599 {
1600 };
1601#endif
1602
1603#if ETL_USING_CPP17
1604 template <typename T, typename... TRest>
1605 inline constexpr bool is_base_of_all_v = etl::is_base_of_all<T, TRest...>::value;
1606#endif
1607
1608#if ETL_USING_CPP11
1609 //***************************************************************************
1612 template <typename TBase, typename... TDerived>
1613 struct is_base_of_any : etl::disjunction<etl::is_base_of<TBase, TDerived>...>
1614 {
1615 };
1616
1617#endif
1618
1619#if ETL_USING_CPP17
1620 template <typename T, typename... TRest>
1621 inline constexpr bool is_base_of_any_v = etl::is_base_of_any<T, TRest...>::value;
1622#endif
1623
1624 //***************************************************************************
1627 //***************************************************************************
1628 // Recursive definition of the type.
1629 template <size_t Index, typename TType>
1631 {
1632 typedef typename nth_base<Index - 1U, typename TType::base_type>::type type;
1633 };
1634
1635 template <typename TType>
1636 struct nth_base<0, TType>
1637 {
1638 typedef TType type;
1639 };
1640
1641#if ETL_USING_CPP11
1642 template <size_t Index, typename TType>
1643 using nth_base_t = typename nth_base<Index, TType>::type;
1644#endif
1645
1646 //***************************************************************************
1649
1650 // Default.
1651 template <typename T>
1652 struct types
1653 {
1654 private:
1655
1656 typedef typename etl::remove_reference<typename etl::remove_cv<T>::type>::type type_t;
1657
1658 public:
1659
1660 typedef type_t type;
1661 typedef type_t& reference;
1662 typedef const type_t& const_reference;
1663 typedef type_t* pointer;
1664 typedef const type_t* const_pointer;
1665 typedef const type_t* const const_pointer_const;
1666
1667#if ETL_USING_CPP11
1668 typedef type_t&& rvalue_reference;
1669#endif
1670 };
1671
1672 // Pointers.
1673 template <typename T>
1674 struct types<T*>
1675 {
1676 private:
1677
1678 typedef typename etl::remove_reference<typename etl::remove_cv<T>::type>::type type_t;
1679
1680 public:
1681
1682 typedef type_t type;
1683 typedef type_t& reference;
1684 typedef const type_t& const_reference;
1685 typedef type_t* pointer;
1686 typedef const type_t* const_pointer;
1687 typedef const type_t* const const_pointer_const;
1688
1689#if ETL_USING_CPP11
1690 typedef type_t&& rvalue_reference;
1691#endif
1692 };
1693
1694 // Pointers.
1695 template <typename T>
1696 struct types<T* const>
1697 {
1698 private:
1699
1700 typedef typename etl::remove_reference<typename etl::remove_cv<T>::type>::type type_t;
1701
1702 public:
1703
1704 typedef type_t type;
1705 typedef type_t& reference;
1706 typedef const type_t& const_reference;
1707 typedef type_t* pointer;
1708 typedef const type_t* const_pointer;
1709 typedef const type_t* const const_pointer_const;
1710
1711#if ETL_USING_CPP11
1712 typedef type_t&& rvalue_reference;
1713#endif
1714 };
1715
1716 // References.
1717 template <typename T>
1718 struct types<T&>
1719 {
1720 private:
1721
1722 typedef typename etl::remove_reference<typename etl::remove_cv<T>::type>::type type_t;
1723
1724 public:
1725
1726 typedef type_t type;
1727 typedef type_t& reference;
1728 typedef const type_t& const_reference;
1729 typedef type_t* pointer;
1730 typedef const type_t* const_pointer;
1731 typedef const type_t* const const_pointer_const;
1732
1733#if ETL_USING_CPP11
1734 typedef type_t&& rvalue_reference;
1735#endif
1736 };
1737
1738#if ETL_USING_CPP11
1739 // rvalue References.
1740 template <typename T>
1741 struct types<T&&>
1742 {
1743 private:
1744
1746
1747 public:
1748
1749 typedef type_t type;
1750 typedef type_t& reference;
1751 typedef const type_t& const_reference;
1752 typedef type_t* pointer;
1753 typedef const type_t* const_pointer;
1754 typedef const type_t* const const_pointer_const;
1755
1756#if ETL_USING_CPP11
1757 typedef type_t&& rvalue_reference;
1758#endif
1759 };
1760#endif
1761
1762#if ETL_USING_CPP11
1763 template <typename T>
1764 using types_t = typename types<T>::type;
1765
1766 template <typename T>
1767 using types_r = typename types<T>::reference;
1768
1769 template <typename T>
1770 using types_cr = typename types<T>::const_reference;
1771
1772 template <typename T>
1773 using types_rr = typename types<T>::rvalue_reference;
1774
1775 template <typename T>
1776 using types_p = typename types<T>::pointer;
1777
1778 template <typename T>
1779 using types_cp = typename types<T>::const_pointer;
1780
1781 template <typename T>
1782 using types_cpc = typename types<T>::const_pointer_const;
1783#endif
1784
1785 //***************************************************************************
1788 template <typename T> struct size_of : etl::integral_constant<size_t, sizeof(T)> {};
1789 template <> struct size_of<void> : etl::integral_constant<size_t, 1U> {};
1790
1791#if ETL_USING_CPP17
1792 template <typename T>
1793 inline constexpr size_t size_of_v = etl::size_of<T>::value;
1794#endif
1795
1796#if ETL_USING_CPP11
1797 //***************************************************************************
1799 template <typename T, typename... TRest>
1800 struct are_all_same : etl::conjunction<etl::is_same<T, TRest>...>
1801 {
1802 };
1803#endif
1804
1805#if ETL_USING_CPP17
1806 template <typename T, typename... TRest>
1807 inline constexpr bool are_all_same_v = are_all_same<T, TRest...>::value;
1808#endif
1809
1810 //***************************************************************************
1811#if ETL_USING_STL && ETL_USING_CPP11 && !defined(ETL_USE_TYPE_TRAITS_BUILTINS) && !defined(ETL_USER_DEFINED_TYPE_TRAITS) && ((!defined(ARDUINO) && ETL_NOT_USING_STLPORT) || defined(ETL_GCC_V5_TYPE_TRAITS_SUPPORTED))
1812
1813 //*********************************************
1814 // Use the STL's definitions.
1815 //*********************************************
1816
1817 //*********************************************
1818 // is_assignable
1819 template<typename T1, typename T2>
1820 using is_assignable = std::is_assignable<T1, T2>;
1821
1822 //*********************************************
1823 // is_constructible
1824 template<typename T, typename... TArgs>
1825 using is_constructible = std::is_constructible<T, TArgs...>;
1826
1827 //*********************************************
1828 // is_copy_constructible
1829 template <typename T>
1830 using is_copy_constructible = std::is_copy_constructible<T>;
1831
1832 //*********************************************
1833 // is_move_constructible
1834 template <typename T>
1835 using is_move_constructible = std::is_move_constructible<T>;
1836
1837 //*********************************************
1838 // is_trivially_constructible
1839#if ETL_CPP11_TYPE_TRAITS_IS_TRIVIAL_SUPPORTED
1840 template <typename T>
1841 using is_trivially_constructible = std::is_trivially_constructible<T>;
1842#else
1843 template <typename T>
1845#endif
1846
1847 //*********************************************
1848 // is_trivially_copy_constructible
1849#if ETL_CPP11_TYPE_TRAITS_IS_TRIVIAL_SUPPORTED
1850 template <typename T>
1851 using is_trivially_copy_constructible = std::is_trivially_copy_constructible<T>;
1852#else
1853 template <typename T>
1854 using is_trivially_copy_constructible = etl::bool_constant<etl::is_arithmetic<T>::value || etl::is_pointer<T>::value>;
1855#endif
1856
1857 //*********************************************
1858 // is_trivially_destructible
1859#if ETL_CPP11_TYPE_TRAITS_IS_TRIVIAL_SUPPORTED
1860 template <typename T>
1861 using is_trivially_destructible = std::is_trivially_destructible<T>;
1862#else
1863 template <typename T>
1865#endif
1866
1867 //*********************************************
1868 // is_trivially_copy_assignable
1869#if ETL_CPP11_TYPE_TRAITS_IS_TRIVIAL_SUPPORTED
1870 template <typename T>
1871 using is_trivially_copy_assignable = std::is_trivially_copy_assignable<T>;
1872#else
1873 template <typename T>
1874 using is_trivially_copy_assignable = etl::bool_constant<etl::is_arithmetic<T>::value || etl::is_pointer<T>::value>;
1875#endif
1876
1877 //*********************************************
1878 // is_trivially_copyable
1879#if ETL_CPP11_TYPE_TRAITS_IS_TRIVIAL_SUPPORTED
1880 template <typename T>
1881 using is_trivially_copyable = std::is_trivially_copyable<T>;
1882#else
1883 template <typename T>
1885#endif
1886
1887#elif defined(ETL_USE_TYPE_TRAITS_BUILTINS) && !defined(ETL_USER_DEFINED_TYPE_TRAITS)
1888
1889 //*********************************************
1890 // Use the compiler's builtins.
1891 //*********************************************
1892
1893 //*********************************************
1894 // is_assignable
1895 template<typename T1, typename T2>
1896 struct is_assignable
1897 {
1898 static ETL_CONSTANT bool value = __is_assignable(T1, T2);
1899 };
1900
1901#if ETL_USING_CPP11
1902 //*********************************************
1903 // is_constructible
1904 template<typename T, typename... TArgs>
1905 struct is_constructible
1906 {
1907 static ETL_CONSTANT bool value = __is_constructible(T, TArgs...);
1908 };
1909#else
1910 //*********************************************
1911 // is_constructible
1912 template<typename T, typename TArgs = void>
1913 struct is_constructible
1914 {
1915 static ETL_CONSTANT bool value = __is_constructible(T, TArgs);
1916 };
1917
1918 //*********************************************
1919 // is_constructible
1920 template<typename T>
1921 struct is_constructible<T, void>
1922 {
1923 static ETL_CONSTANT bool value = __is_constructible(T);
1924 };
1925#endif
1926
1927 //*********************************************
1928 // is_copy_constructible
1929 template <typename T>
1930 struct is_copy_constructible : public etl::is_constructible<T, typename etl::add_lvalue_reference<const T>::type>
1931 {
1932 };
1933
1934 //*********************************************
1935 // is_move_constructible
1936 template <typename T>
1937 struct is_move_constructible : public etl::is_constructible<T, T>
1938 {
1939 };
1940
1941#if ETL_USING_CPP11
1942 //*********************************************
1943 // is_trivially_constructible
1944 template <typename T, typename... TArgs>
1946 {
1947#if defined(ETL_COMPILER_GCC)
1948 static ETL_CONSTANT bool value = __has_trivial_constructor(T);
1949#else
1950 static ETL_CONSTANT bool value = __is_trivially_constructible(T, TArgs...);
1951#endif
1952 };
1953#else
1954 //*********************************************
1955 // is_trivially_constructible
1956 template <typename T, typename TArgs = void>
1958 {
1959#if defined(ETL_COMPILER_GCC)
1960 static ETL_CONSTANT bool value = __has_trivial_constructor(T);
1961#else
1962 static ETL_CONSTANT bool value = __is_trivially_constructible(T, TArgs);
1963#endif
1964 };
1965
1966 //*********************************************
1967 // is_trivially_constructible
1968 template <typename T>
1969 struct is_trivially_constructible<T, void>
1970 {
1971#if defined(ETL_COMPILER_GCC)
1972 static ETL_CONSTANT bool value = __has_trivial_constructor(T);
1973#else
1974 static ETL_CONSTANT bool value = __is_trivially_constructible(T);
1975#endif
1976 };
1977#endif
1978
1979 //*********************************************
1980 // is_trivially_copy_constructible
1981 template <typename T>
1982 struct is_trivially_copy_constructible : public is_trivially_constructible<T, typename add_lvalue_reference<const T>::type>
1983 {
1984 };
1985
1986 //*********************************************
1987 // is_trivially_destructible
1988 template <typename T>
1990 {
1991#if defined(ETL_COMPILER_GCC)
1992 static ETL_CONSTANT bool value = __has_trivial_destructor(T);
1993#else
1994 static ETL_CONSTANT bool value = __is_trivially_destructible(T);
1995#endif
1996 };
1997
1998 //*********************************************
1999 // is_trivially_copy_assignable
2000 template <typename T>
2002 {
2003#if defined(ETL_COMPILER_GCC)
2004 static ETL_CONSTANT bool value = __has_trivial_copy(T);
2005#else
2006 static ETL_CONSTANT bool value = __is_trivially_copyable(T);
2007#endif
2008 };
2009
2010 //*********************************************
2011 // is_trivially_copyable
2012 template <typename T>
2014 {
2015#if defined(ETL_COMPILER_GCC)
2016 static ETL_CONSTANT bool value = __has_trivial_copy(T);
2017#else
2018 static ETL_CONSTANT bool value = __is_trivially_copyable(T);
2019#endif
2020 };
2021
2022#elif defined(ETL_USER_DEFINED_TYPE_TRAITS) && !defined(ETL_USE_TYPE_TRAITS_BUILTINS)
2023
2024 //*********************************************
2025 // Force the user to provide specialisations for
2026 // anything other than arithmetics and pointers.
2027 //*********************************************
2028
2029 //*********************************************
2030 // is_assignable
2031 template <typename T1,
2032 typename T2,
2033 bool BValue = (etl::is_arithmetic<T1>::value || etl::is_pointer<T1>::value) && (etl::is_arithmetic<T2>::value || etl::is_pointer<T2>::value)>
2034 struct is_assignable;
2035
2036 template <typename T1, typename T2>
2037 struct is_assignable<T1, T2, true> : public etl::true_type
2038 {
2039 };
2040
2041 template <typename T1, typename T2>
2042 struct is_assignable<T1, T2, false>;
2043
2044#if ETL_USING_CPP11
2045 //*********************************************
2046 // is_constructible
2047 template <typename T, bool BValue, typename... TArgs>
2048 struct is_constructible_helper;
2049
2050 template <typename T, typename... TArgs>
2051 struct is_constructible_helper<T, true, TArgs...> : public etl::true_type
2052 {
2053 };
2054
2055 template <typename T, typename... TArgs>
2056 struct is_constructible_helper<T, false, TArgs...>;
2057
2058 template <typename T, typename... TArgs>
2059 struct is_constructible : public is_constructible_helper<T, etl::is_arithmetic<T>::value || etl::is_pointer<T>::value, TArgs...>
2060 {
2061 };
2062#endif
2063
2064 //*********************************************
2065 // is_copy_constructible
2066 template <typename T, bool BValue = etl::is_arithmetic<T>::value || etl::is_pointer<T>::value>
2067 struct is_copy_constructible;
2068
2069 template <typename T>
2070 struct is_copy_constructible<T, true> : public etl::true_type
2071 {
2072 };
2073
2074 template <typename T>
2075 struct is_copy_constructible<T, false>;
2076
2077 //*********************************************
2078 // is_move_constructible
2079 template <typename T, bool BValue = etl::is_arithmetic<T>::value || etl::is_pointer<T>::value>
2080 struct is_move_constructible;
2081
2082 template <typename T>
2083 struct is_move_constructible<T, true> : public etl::true_type
2084 {
2085 };
2086
2087 template <typename T>
2088 struct is_move_constructible<T, false>;
2089
2090 //*********************************************
2091 // is_trivially_constructible
2092 template <typename T, bool BValue = etl::is_arithmetic<T>::value || etl::is_pointer<T>::value>
2094
2095 template <typename T>
2096 struct is_trivially_constructible<T, true> : public etl::true_type
2097 {
2098 };
2099
2100 template <typename T>
2101 struct is_trivially_constructible<T, false>;
2102
2103 //*********************************************
2104 // is_trivially_copy_constructible
2105 template <typename T, bool BValue = etl::is_arithmetic<T>::value || etl::is_pointer<T>::value>
2107
2108 template <typename T>
2109 struct is_trivially_copy_constructible<T, true> : public etl::true_type
2110 {
2111 };
2112
2113 template <typename T>
2114 struct is_trivially_copy_constructible<T, false>;
2115
2116 //*********************************************
2117 // is_trivially_destructible
2118 template <typename T, bool BValue = etl::is_arithmetic<T>::value || etl::is_pointer<T>::value>
2120
2121 template <typename T>
2122 struct is_trivially_destructible<T, true> : public etl::true_type
2123 {
2124 };
2125
2126 template <typename T>
2127 struct is_trivially_destructible<T, false>;
2128
2129 //*********************************************
2130 // is_trivially_copy_assignable
2131 template <typename T, bool BValue = etl::is_arithmetic<T>::value || etl::is_pointer<T>::value>
2133
2134 template <typename T>
2135 struct is_trivially_copy_assignable<T, true> : public etl::true_type
2136 {
2137 };
2138
2139 template <typename T>
2140 struct is_trivially_copy_assignable<T, false>;
2141
2142 //*********************************************
2143 // is_trivially_copyable
2144 template <typename T, bool BValue = etl::is_arithmetic<T>::value || etl::is_pointer<T>::value>
2145 struct is_trivially_copyable;
2146
2147 template <typename T>
2148 struct is_trivially_copyable<T, true> : public etl::true_type
2149 {
2150 };
2151
2152 template <typename T>
2153 struct is_trivially_copyable<T, false>;
2154
2155#else
2156
2157 //*********************************************
2158 // Assume that anything other than arithmetics
2159 // and pointers return false for the traits.
2160 //*********************************************
2161
2162 //*********************************************
2163 // is_assignable
2164 template <typename T1, typename T2>
2165 struct is_assignable : public etl::bool_constant<(etl::is_arithmetic<T1>::value || etl::is_pointer<T1>::value) && (etl::is_arithmetic<T2>::value || etl::is_pointer<T2>::value)>
2166 {
2167 };
2168
2169#if ETL_USING_CPP11
2170 //***************************************************************************
2172 namespace private_type_traits
2173 {
2174 template <class, class T, class... TArgs>
2175 struct is_constructible_ : etl::false_type {};
2176
2177 template <class T, class... TArgs>
2178 struct is_constructible_<void_t<decltype(T(etl::declval<TArgs>()...))>, T, TArgs...> : etl::true_type {};
2179 }
2180
2181 //*********************************************
2182 // is_constructible
2183 template <class T, class... TArgs>
2184 using is_constructible = private_type_traits::is_constructible_<void_t<>, T, TArgs...>;
2185
2186 //*********************************************
2187 // is_copy_constructible
2188 template <class T> struct is_copy_constructible : public is_constructible<T, typename etl::add_lvalue_reference<typename etl::add_const<T>::type>::type>{};
2189 template <> struct is_copy_constructible<void> : public false_type{};
2190 template <> struct is_copy_constructible<void const> : public false_type{};
2191 template <> struct is_copy_constructible<void volatile> : public false_type{};
2192 template <> struct is_copy_constructible<void const volatile> : public false_type{};
2193
2194 //*********************************************
2195 // is_move_constructible
2196 template <typename T> struct is_move_constructible: public is_constructible<T, typename etl::add_rvalue_reference<T>::type>{};
2197 template <> struct is_move_constructible<void> : public false_type{};
2198 template <> struct is_move_constructible<void const> : public false_type{};
2199 template <> struct is_move_constructible<void volatile> : public false_type{};
2200 template <> struct is_move_constructible<void const volatile> : public false_type{};
2201
2202#else
2203
2204 //*********************************************
2205 // is_copy_constructible
2206 template <typename T>
2207 struct is_copy_constructible : public etl::bool_constant<etl::is_arithmetic<T>::value || etl::is_pointer<T>::value>
2208 {
2209 };
2210
2211 //*********************************************
2212 // is_move_constructible
2213 template <typename T>
2214 struct is_move_constructible : public etl::bool_constant<etl::is_arithmetic<T>::value || etl::is_pointer<T>::value>
2215 {
2216 };
2217#endif
2218
2219 //*********************************************
2220 // is_trivially_constructible
2221 template <typename T>
2222 struct is_trivially_constructible : public etl::bool_constant<etl::is_arithmetic<T>::value || etl::is_pointer<T>::value>
2223 {
2224 };
2225
2226 //*********************************************
2227 // is_trivially_copy_constructible
2228 template <typename T>
2229 struct is_trivially_copy_constructible : public etl::bool_constant<etl::is_arithmetic<T>::value || etl::is_pointer<T>::value>
2230 {
2231 };
2232
2233 //*********************************************
2234 // is_trivially_destructible
2235 template <typename T>
2236 struct is_trivially_destructible : public etl::bool_constant<etl::is_arithmetic<T>::value || etl::is_pointer<T>::value>
2237 {
2238 };
2239
2240 //*********************************************
2241 // is_trivially_copy_assignable
2242 template <typename T>
2243 struct is_trivially_copy_assignable : public etl::bool_constant<etl::is_arithmetic<T>::value || etl::is_pointer<T>::value>
2244 {
2245 };
2246
2247 //*********************************************
2248 // is_trivially_copyable
2249 template <typename T>
2250 struct is_trivially_copyable : public etl::bool_constant<etl::is_arithmetic<T>::value || etl::is_pointer<T>::value>
2251 {
2252 };
2253
2254#endif
2255
2256 template <typename T1, typename T2>
2257 struct is_lvalue_assignable : public etl::is_assignable<typename etl::add_lvalue_reference<T1>::type,
2258 typename etl::add_lvalue_reference<typename etl::add_const<T2>::type>::type>
2259 {
2260 };
2261
2262#if ETL_USING_CPP11
2263 //*********************************************
2264 // is_default_constructible
2265 template<typename T, typename = void>
2267
2268 template<typename T>
2269 struct is_default_constructible<T, etl::void_t<decltype(T())>> : etl::true_type { };
2270#else
2271 template <typename T>
2272 struct is_default_constructible : public etl::bool_constant<etl::is_arithmetic<T>::value || etl::is_pointer<T>::value>
2273 {
2274 };
2275#endif
2276
2277#if ETL_USING_CPP17
2278
2279 template <typename T1, typename T2>
2280 inline constexpr bool is_assignable_v = etl::is_assignable<T1, T2>::value;
2281
2282 template <typename T1, typename T2>
2283 inline constexpr bool is_lvalue_assignable_v = etl::is_lvalue_assignable<T1, T2>::value;
2284
2285 template<typename T, typename... TArgs>
2286 inline constexpr bool is_constructible_v = etl::is_constructible<T, TArgs...>::value;
2287
2288 template<typename T, typename... TArgs>
2289 inline constexpr bool is_default_constructible_v = etl::is_default_constructible<T, TArgs...>::value;
2290
2291 template<typename T>
2292 inline constexpr bool is_copy_constructible_v = etl::is_copy_constructible<T>::value;
2293
2294 template<typename T>
2295 inline constexpr bool is_move_constructible_v = etl::is_move_constructible<T>::value;
2296
2297 template <typename T>
2298 inline constexpr bool is_trivially_constructible_v = etl::is_trivially_constructible<T>::value;
2299
2300 template <typename T>
2301 inline constexpr bool is_trivially_copy_constructible_v = etl::is_trivially_copy_constructible<T>::value;
2302
2303 template <typename T>
2304 inline constexpr bool is_trivially_destructible_v = etl::is_trivially_destructible<T>::value;
2305
2306 template <typename T>
2307 inline constexpr bool is_trivially_copy_assignable_v = etl::is_trivially_copy_assignable<T>::value;
2308
2309 template <typename T>
2310 inline constexpr bool is_trivially_copyable_v = etl::is_trivially_copyable<T>::value;
2311
2312#endif
2313
2314#if ETL_USING_CPP11
2315 //*********************************************
2316 // common_type
2317 // Based on the sample implementation detailed on
2318 // https://en.cppreference.com/w/cpp/types/common_type
2319 //*********************************************
2320 //***********************************
2321 // Primary template
2322 template<typename...>
2323 struct common_type
2324 {
2325 };
2326
2327 //***********************************
2328 // One type
2329 template <typename T>
2330 struct common_type<T> : common_type<T, T>
2331 {
2332 };
2333
2334 namespace private_common_type
2335 {
2336 template <typename T1, typename T2>
2337 using conditional_result_t = decltype(false ? declval<T1>() : declval<T2>());
2338
2339 template <typename, typename, typename = void>
2340 struct decay_conditional_result
2341 {
2342 };
2343
2344 template <typename T1, typename T2>
2345 struct decay_conditional_result<T1, T2, void_t<conditional_result_t<T1, T2>>>
2346 : etl::decay<conditional_result_t<T1, T2>>
2347 {
2348 };
2349
2350 template <typename T1, typename T2, typename = void>
2351 struct common_type_2_impl
2352 : decay_conditional_result<const T1&, const T2&>
2353 {
2354 };
2355
2356 template <typename T1, typename T2>
2357 struct common_type_2_impl<T1, T2, void_t<conditional_result_t<T1, T2>>>
2358 : decay_conditional_result<T1, T2>
2359 {
2360 };
2361 }
2362
2363 //***********************************
2364 // Two types
2365 template <typename T1, typename T2>
2366 struct common_type<T1, T2>
2367 : etl::conditional<etl::is_same<T1, typename etl::decay<T1>::type>::value&& etl::is_same<T2, typename etl::decay<T2>::type>::value,
2368 private_common_type::common_type_2_impl<T1, T2>,
2369 common_type<typename etl::decay<T2>::type,
2370 typename etl::decay<T2>::type>>::type
2371 {
2372 };
2373
2374 //***********************************
2375 // Three or more types
2376 namespace private_common_type
2377 {
2378 template <typename AlwaysVoid, typename T1, typename T2, typename... TRest>
2379 struct common_type_multi_impl
2380 {
2381 };
2382
2383 template <typename T1, typename T2, typename... TRest>
2384 struct common_type_multi_impl<void_t<typename common_type<T1, T2>::type>, T1, T2, TRest...>
2385 : common_type<typename common_type<T1, T2>::type, TRest...>
2386 {
2387 };
2388 }
2389
2390 template<typename T1, typename T2, typename... TRest>
2391 struct common_type<T1, T2, TRest...>
2392 : private_common_type::common_type_multi_impl<void, T1, T2, TRest...>
2393 {
2394 };
2395
2396 template <typename... T>
2397 using common_type_t = typename common_type<T...>::type;
2398#endif
2399
2400 //***************************************************************************
2402 //***************************************************************************
2403 template <typename T>
2405 {
2406 typedef typename etl::conditional<sizeof(T) == sizeof(unsigned char), unsigned char,
2407 typename etl::conditional<sizeof(T) == sizeof(unsigned short), unsigned short,
2408 typename etl::conditional<sizeof(T) == sizeof(unsigned int), unsigned int,
2409 typename etl::conditional<sizeof(T) == sizeof(unsigned long), unsigned long,
2410 unsigned long long>::type>::type>::type>::type type;
2411 };
2412
2413#if ETL_USING_CPP11
2414 template <typename T>
2415 using unsigned_type_t = typename unsigned_type<T>::type;
2416#endif
2417
2418 //***************************************************************************
2420 //***************************************************************************
2421 template <typename T>
2423 {
2424 typedef typename etl::conditional<sizeof(T) == sizeof(char), char,
2425 typename etl::conditional<sizeof(T) == sizeof(short), short,
2426 typename etl::conditional<sizeof(T) == sizeof(int), int,
2427 typename etl::conditional<sizeof(T) == sizeof(long), long,
2428 long long>::type>::type>::type>::type type;
2429 };
2430
2431#if ETL_USING_CPP11
2432 template <typename T>
2433 using signed_type_t = typename signed_type<T>::type;
2434#endif
2435
2436 //*********************************************
2437 // type_identity
2438
2439 template <typename T>
2440 struct type_identity { typedef T type; };
2441
2442#if ETL_USING_CPP11
2443 template <typename T>
2444 using type_identity_t = typename type_identity<T>::type;
2445#endif
2446
2447 //*********************************************
2448 // underlying_type
2449#if ETL_USING_BUILTIN_UNDERLYING_TYPE
2450 // Primary template for etl::underlying_type
2451 template <typename T, bool = etl::is_enum<T>::value>
2452 struct underlying_type;
2453
2454 // Specialization for non-enum types (invalid case)
2455 template <typename T>
2456 struct underlying_type<T, false>
2457 {
2458 // Static assertion to ensure this is only used with enums
2459 ETL_STATIC_ASSERT(etl::is_enum<T>::value, "etl::underlying_type can only be used with enumeration types.");
2460 };
2461
2462 template <typename T>
2463 struct underlying_type<T, true>
2464 {
2465 typedef __underlying_type(T) type;
2466 };
2467#else
2470 template <typename T>
2472 {
2473 typedef int type;
2474 };
2475#endif
2476
2477#if ETL_USING_CPP11
2478 template <typename T>
2479 using underlying_type_t = typename underlying_type<T>::type;
2480#endif
2481
2482#if ETL_USING_CPP11
2483 //*********************************************
2484 // has_duplicates
2485 template <typename... TTypes>
2486 struct has_duplicates;
2487
2488 template <typename TFirst, typename... TRest>
2489 struct has_duplicates<TFirst, TRest...> : etl::conditional_t<etl::is_one_of<TFirst, TRest...>::value,
2490 etl::true_type,
2491 has_duplicates<TRest...>> {};
2492
2493 template <typename T>
2494 struct has_duplicates<T> : etl::false_type {};
2495
2496 template <>
2497 struct has_duplicates<> : etl::false_type {};
2498#endif
2499
2500#if ETL_USING_CPP17
2501 template <typename... TTypes>
2502 inline constexpr bool has_duplicates_v = etl::has_duplicates<TTypes...>::value;
2503#endif
2504
2505#if ETL_USING_CPP11
2506 //*********************************************
2507 // count_of
2508 template <typename T, typename... TTypes>
2509 struct count_of;
2510
2511 template <typename T, typename U, typename... URest>
2512 struct count_of<T, U, URest...> : etl::integral_constant<size_t,
2513 etl::is_same<T, U>::value +
2514 count_of<T, URest...>::value> {};
2515
2516 template <typename T>
2517 struct count_of<T> : etl::integral_constant<size_t, 0> {};
2518#endif
2519
2520#if ETL_USING_CPP17
2521 template <typename T, typename... TTypes>
2522 inline constexpr size_t count_of_v = etl::count_of<T, TTypes...>::value;
2523#endif
2524
2525#if ETL_USING_CPP11
2526 //*********************************************
2528 template <typename T, template <typename...> class Template>
2529 struct is_specialization : etl::false_type {};
2530
2531 template <template <typename...> class Template, typename... TArgs>
2532 struct is_specialization<Template<TArgs...>, Template> : etl::true_type {};
2533#endif
2534
2535#if ETL_USING_CPP17
2536 template <typename T, template <typename...> class Template>
2537 inline constexpr bool is_specialization_v = etl::is_specialization<T, Template>::value;
2538#endif
2539
2540 //*********************************************
2541 // is_constant_evaluated
2542 ETL_CONSTEXPR inline bool is_constant_evaluated() ETL_NOEXCEPT
2543 {
2544#if ETL_USING_CPP23
2545 if consteval
2546 {
2547 return true;
2548 }
2549 else
2550 {
2551 return false;
2552 }
2553#elif ETL_USING_BUILTIN_IS_CONSTANT_EVALUATED == 1
2554 // Fallback for C++20 on supported compilers
2555 return __builtin_is_constant_evaluated();
2556#else
2557 // default if unsupported
2558 return false;
2559#endif
2560 }
2561
2562#if ETL_USING_CPP11
2563 //*********************************
2565 //*********************************
2566 template<typename T>
2567 struct is_function : etl::false_type
2568 {
2569 };
2570
2571 // Plain / cv-qualified
2572 template<typename TReturn, typename... TArgs>
2573 struct is_function<TReturn(TArgs...)> : etl::true_type {};
2574
2575 template<typename TReturn, typename... TArgs>
2576 struct is_function<TReturn(TArgs...) const> : etl::true_type {};
2577
2578 template<typename TReturn, typename... TArgs>
2579 struct is_function<TReturn(TArgs...) volatile> : etl::true_type {};
2580
2581 template<typename TReturn, typename... TArgs>
2582 struct is_function<TReturn(TArgs...) const volatile> : etl::true_type {};
2583
2584 // Variadic
2585 template<typename TReturn, typename... TArgs>
2586 struct is_function<TReturn(TArgs..., ...)> : etl::true_type {};
2587
2588 template<typename TReturn, typename... TArgs>
2589 struct is_function<TReturn(TArgs..., ...) const> : etl::true_type {};
2590
2591 template<typename TReturn, typename... TArgs>
2592 struct is_function<TReturn(TArgs..., ...) volatile> : etl::true_type {};
2593
2594 template<typename TReturn, typename... TArgs>
2595 struct is_function<TReturn(TArgs..., ...) const volatile> : etl::true_type {};
2596
2597 // noexcept variants (if supported)
2598#if ETL_HAS_NOEXCEPT_FUNCTION_TYPE
2599 template<typename TReturn, typename... TArgs>
2600 struct is_function<TReturn(TArgs...) noexcept> : etl::true_type {};
2601
2602 template<typename TReturn, typename... TArgs>
2603 struct is_function<TReturn(TArgs...) const noexcept> : etl::true_type {};
2604
2605 template<typename TReturn, typename... TArgs>
2606 struct is_function<TReturn(TArgs...) volatile noexcept> : etl::true_type {};
2607
2608 template<typename TReturn, typename... TArgs>
2609 struct is_function<TReturn(TArgs...) const volatile noexcept> : etl::true_type {};
2610
2611
2612 template<typename TReturn, typename... TArgs>
2613 struct is_function<TReturn(TArgs..., ...) noexcept> : etl::true_type {};
2614
2615 template<typename TReturn, typename... TArgs>
2616 struct is_function<TReturn(TArgs..., ...) const noexcept> : etl::true_type {};
2617
2618 template<typename TReturn, typename... TArgs>
2619 struct is_function<TReturn(TArgs..., ...) volatile noexcept> : etl::true_type {};
2620
2621 template<typename TReturn, typename... TArgs>
2622 struct is_function<TReturn(TArgs..., ...) const volatile noexcept> : etl::true_type {};
2623#endif
2624
2625#if ETL_USING_CPP17
2626 template <typename T>
2627 inline constexpr bool is_function_v = etl::is_function<T>::value;
2628#endif
2629#endif
2630
2631#if ETL_USING_CPP11
2632 //*********************************
2634 //*********************************
2635 template <typename T, etl::enable_if_t<etl::is_class<etl::decay_t<T>>::value, int> = 0>
2636 struct has_call_operator
2637 {
2638 template <typename U>
2639 static auto test(int) -> decltype(&U::operator(), etl::true_type());
2640
2641 template <typename>
2642 static etl::false_type test(...);
2643
2644 static const bool value = etl::is_same<decltype(test<T>(0)), etl::true_type>::value;
2645 };
2646
2647#if ETL_USING_CPP17
2648 template <typename T>
2649 inline constexpr bool has_call_operator_v = etl::has_call_operator<T>::value;
2650#endif
2651#endif
2652
2653#if ETL_USING_CPP11
2654 //***************************************************************************
2656 //***************************************************************************
2657 template <typename T, etl::enable_if_t<etl::is_class<etl::decay_t<T>>::value, int> = 0>
2658 struct has_unique_call_operator
2659 {
2660 //*********************************
2661 // Test for presence of operator()
2662 //*********************************
2663 template <typename U>
2664 static auto test(int) -> decltype(&U::operator(), etl::true_type());
2665
2666 //*********************************
2667 // Fallback
2668 //*********************************
2669 template <typename>
2670 static auto test(...) -> etl::false_type;
2671
2672 //*********************************
2673 // <b>true</b> if operator() exists and is unique
2674 //*********************************
2675 static constexpr bool value = decltype(test<etl::decay_t<T>>(0))::value;
2676 };
2677
2678#if ETL_USING_CPP17
2679 template <typename T>
2680 inline constexpr bool has_unique_call_operator_v = etl::has_unique_call_operator<T>::value;
2681#endif
2682#endif
2683
2684 //***************************************************************************
2686 //***************************************************************************
2688 {
2689 template<typename T>
2691
2692 template<typename T, typename TObject>
2693 struct is_member_pointer_helper<T TObject::*> : etl::true_type {};
2694 }
2695
2696 template<typename T>
2697 struct is_member_pointer : private_type_traits::is_member_pointer_helper<typename etl::remove_cv<T>::type> {};
2698
2699#if ETL_USING_CPP17
2700 template <typename T>
2701 inline constexpr bool is_member_pointer_v = etl::is_member_pointer<T>::value;
2702#endif
2703
2704#if ETL_USING_CPP11
2705 //***************************************************************************
2707 //***************************************************************************
2708 template <typename T> struct is_member_function_pointer : etl::false_type {};
2709
2710 template <typename TReturn, typename TObject, typename... TArgs> struct is_member_function_pointer<TReturn(TObject::*)(TArgs...)> : etl::true_type {};
2711 template <typename TReturn, typename TObject, typename... TArgs> struct is_member_function_pointer<TReturn(TObject::*)(TArgs...) const> : etl::true_type {};
2712 template <typename TReturn, typename TObject, typename... TArgs> struct is_member_function_pointer<TReturn(TObject::*)(TArgs...) volatile> : etl::true_type {};
2713 template <typename TReturn, typename TObject, typename... TArgs> struct is_member_function_pointer<TReturn(TObject::*)(TArgs...) const volatile> : etl::true_type {};
2714
2715#if ETL_HAS_NOEXCEPT_FUNCTION_TYPE
2716 template <typename TReturn, typename TObject, typename... TArgs> struct is_member_function_pointer<TReturn(TObject::*)(TArgs...) noexcept> : etl::true_type {};
2717 template <typename TReturn, typename TObject, typename... TArgs> struct is_member_function_pointer<TReturn(TObject::*)(TArgs...) const noexcept> : etl::true_type {};
2718 template <typename TReturn, typename TObject, typename... TArgs> struct is_member_function_pointer<TReturn(TObject::*)(TArgs...) volatile noexcept> : etl::true_type {};
2719 template <typename TReturn, typename TObject, typename... TArgs> struct is_member_function_pointer<TReturn(TObject::*)(TArgs...) const volatile noexcept> : etl::true_type {};
2720#endif
2721
2722 template <typename TReturn, typename TObject, typename... TArgs> struct is_member_function_pointer<TReturn(TObject::*)(TArgs...) &> : etl::true_type {};
2723 template <typename TReturn, typename TObject, typename... TArgs> struct is_member_function_pointer<TReturn(TObject::*)(TArgs...) const &> : etl::true_type {};
2724 template <typename TReturn, typename TObject, typename... TArgs> struct is_member_function_pointer<TReturn(TObject::*)(TArgs...) volatile &> : etl::true_type {};
2725 template <typename TReturn, typename TObject, typename... TArgs> struct is_member_function_pointer<TReturn(TObject::*)(TArgs...) const volatile &> : etl::true_type {};
2726
2727 template <typename TReturn, typename TObject, typename... TArgs> struct is_member_function_pointer<TReturn(TObject::*)(TArgs...) &&> : etl::true_type {};
2728 template <typename TReturn, typename TObject, typename... TArgs> struct is_member_function_pointer<TReturn(TObject::*)(TArgs...) const &&> : etl::true_type {};
2729 template <typename TReturn, typename TObject, typename... TArgs> struct is_member_function_pointer<TReturn(TObject::*)(TArgs...) volatile &&> : etl::true_type {};
2730 template <typename TReturn, typename TObject, typename... TArgs> struct is_member_function_pointer<TReturn(TObject::*)(TArgs...) const volatile &&>: etl::true_type {};
2731
2732#if ETL_HAS_NOEXCEPT_FUNCTION_TYPE
2733 template <typename TReturn, typename TObject, typename... TArgs> struct is_member_function_pointer<TReturn(TObject::*)(TArgs...) & noexcept> : etl::true_type {};
2734 template <typename TReturn, typename TObject, typename... TArgs> struct is_member_function_pointer<TReturn(TObject::*)(TArgs...) const & noexcept> : etl::true_type {};
2735 template <typename TReturn, typename TObject, typename... TArgs> struct is_member_function_pointer<TReturn(TObject::*)(TArgs...) volatile & noexcept> : etl::true_type {};
2736 template <typename TReturn, typename TObject, typename... TArgs> struct is_member_function_pointer<TReturn(TObject::*)(TArgs...) const volatile & noexcept> : etl::true_type {};
2737
2738 template <typename TReturn, typename TObject, typename... TArgs> struct is_member_function_pointer<TReturn(TObject::*)(TArgs...) && noexcept> : etl::true_type {};
2739 template <typename TReturn, typename TObject, typename... TArgs> struct is_member_function_pointer<TReturn(TObject::*)(TArgs...) const && noexcept> : etl::true_type {};
2740 template <typename TReturn, typename TObject, typename... TArgs> struct is_member_function_pointer<TReturn(TObject::*)(TArgs...) volatile && noexcept> : etl::true_type {};
2741 template <typename TReturn, typename TObject, typename... TArgs> struct is_member_function_pointer<TReturn(TObject::*)(TArgs...) const volatile && noexcept>: etl::true_type {};
2742#endif
2743
2744 template <typename TReturn, typename TObject, typename... TArgs> struct is_member_function_pointer<TReturn(TObject::*)(TArgs..., ...)> : etl::true_type {};
2745 template <typename TReturn, typename TObject, typename... TArgs> struct is_member_function_pointer<TReturn(TObject::*)(TArgs..., ...) const> : etl::true_type {};
2746 template <typename TReturn, typename TObject, typename... TArgs> struct is_member_function_pointer<TReturn(TObject::*)(TArgs..., ...) volatile> : etl::true_type {};
2747 template <typename TReturn, typename TObject, typename... TArgs> struct is_member_function_pointer<TReturn(TObject::*)(TArgs..., ...) const volatile> : etl::true_type {};
2748
2749#if ETL_HAS_NOEXCEPT_FUNCTION_TYPE
2750 template <typename TReturn, typename TObject, typename... TArgs> struct is_member_function_pointer<TReturn(TObject::*)(TArgs..., ...) noexcept> : etl::true_type {};
2751 template <typename TReturn, typename TObject, typename... TArgs> struct is_member_function_pointer<TReturn(TObject::*)(TArgs..., ...) const noexcept> : etl::true_type {};
2752 template <typename TReturn, typename TObject, typename... TArgs> struct is_member_function_pointer<TReturn(TObject::*)(TArgs..., ...) volatile noexcept> : etl::true_type {};
2753 template <typename TReturn, typename TObject, typename... TArgs> struct is_member_function_pointer<TReturn(TObject::*)(TArgs..., ...) const volatile noexcept> : etl::true_type {};
2754#endif
2755
2756 template <typename TReturn, typename TObject, typename... TArgs> struct is_member_function_pointer<TReturn(TObject::*)(TArgs..., ...) &> : etl::true_type {};
2757 template <typename TReturn, typename TObject, typename... TArgs> struct is_member_function_pointer<TReturn(TObject::*)(TArgs..., ...) const &> : etl::true_type {};
2758 template <typename TReturn, typename TObject, typename... TArgs> struct is_member_function_pointer<TReturn(TObject::*)(TArgs..., ...) volatile &> : etl::true_type {};
2759 template <typename TReturn, typename TObject, typename... TArgs> struct is_member_function_pointer<TReturn(TObject::*)(TArgs..., ...) const volatile &> : etl::true_type {};
2760 template <typename TReturn, typename TObject, typename... TArgs> struct is_member_function_pointer<TReturn(TObject::*)(TArgs..., ...) &&> : etl::true_type {};
2761 template <typename TReturn, typename TObject, typename... TArgs> struct is_member_function_pointer<TReturn(TObject::*)(TArgs..., ...) const &&> : etl::true_type {};
2762 template <typename TReturn, typename TObject, typename... TArgs> struct is_member_function_pointer<TReturn(TObject::*)(TArgs..., ...) volatile &&> : etl::true_type {};
2763 template <typename TReturn, typename TObject, typename... TArgs> struct is_member_function_pointer<TReturn(TObject::*)(TArgs..., ...) const volatile &&>: etl::true_type {};
2764
2765#if ETL_HAS_NOEXCEPT_FUNCTION_TYPE
2766 template <typename TReturn, typename TObject, typename... TArgs> struct is_member_function_pointer<TReturn(TObject::*)(TArgs..., ...) & noexcept> : etl::true_type {};
2767 template <typename TReturn, typename TObject, typename... TArgs> struct is_member_function_pointer<TReturn(TObject::*)(TArgs..., ...) const & noexcept> : etl::true_type {};
2768 template <typename TReturn, typename TObject, typename... TArgs> struct is_member_function_pointer<TReturn(TObject::*)(TArgs..., ...) volatile & noexcept> : etl::true_type {};
2769 template <typename TReturn, typename TObject, typename... TArgs> struct is_member_function_pointer<TReturn(TObject::*)(TArgs..., ...) const volatile & noexcept> : etl::true_type {};
2770
2771 template <typename TReturn, typename TObject, typename... TArgs> struct is_member_function_pointer<TReturn(TObject::*)(TArgs..., ...) && noexcept> : etl::true_type {};
2772 template <typename TReturn, typename TObject, typename... TArgs> struct is_member_function_pointer<TReturn(TObject::*)(TArgs..., ...) const && noexcept> : etl::true_type {};
2773 template <typename TReturn, typename TObject, typename... TArgs> struct is_member_function_pointer<TReturn(TObject::*)(TArgs..., ...) volatile && noexcept> : etl::true_type {};
2774 template <typename TReturn, typename TObject, typename... TArgs> struct is_member_function_pointer<TReturn(TObject::*)(TArgs..., ...) const volatile && noexcept>: etl::true_type {};
2775#endif
2776#endif
2777
2778#if ETL_USING_CPP17
2779 template <typename T>
2780 inline constexpr bool is_member_function_pointer_v = etl::is_member_function_pointer<T>::value;
2781#endif
2782
2783#if ETL_USING_CPP11
2784 //***************************************************************************
2786 //***************************************************************************
2787 namespace private_type_traits
2788 {
2789 template<typename>
2790 struct is_member_object_pointer_helper : public etl::false_type {};
2791
2792 template<typename T, typename TObject>
2793 struct is_member_object_pointer_helper<T TObject::*> : public etl::negation<etl::is_function<T>> {};
2794 }
2795
2796 template<typename T> struct is_member_object_pointer : public private_type_traits::is_member_object_pointer_helper<etl::remove_cv_t<T>>::type {};
2797#endif
2798
2799#if ETL_USING_CPP17
2800 template <typename T>
2801 inline constexpr bool is_member_object_pointer_v = etl::is_member_object_pointer<T>::value;
2802#endif
2803}
2804
2805// Helper macros
2806#define ETL_IS_CHAR_TYPE(type) (etl::is_same<char, type>::value || etl::is_same<signed char, type>::value || etl::is_same<unsigned char, type>::value)
2807#define ETL_IS_NOT_CHAR_TYPE(type) (!ETL_IS_CHAR_TYPE(type))
2808
2809#define ETL_IS_POINTER_TYPE(type) (etl::is_pointer<type>::value)
2810#define ETL_IS_NOT_POINTER_TYPE(type) (!ETL_IS_POINTER_TYPE(type))
2811
2812#define ETL_TARGET_IS_TRIVIALLY_COPYABLE(type) (etl::is_trivially_copyable<typename etl::iterator_traits<type>::value_type>::value)
2813#define ETL_TARGET_IS_NOT_TRIVIALLY_COPYABLE(type) (!ETL_TARGET_IS_TRIVIALLY_COPYABLE(type))
2814
2815#endif // ETL_TYPE_TRAITS_INCLUDED
integral_constant< bool, false > false_type
integral_constant specialisations
Definition type_traits_generator.h:899
add_const
Definition type_traits_generator.h:991
add_cv
Definition type_traits_generator.h:1041
add_pointer
Definition type_traits_generator.h:961
add_volatile
Definition type_traits_generator.h:1021
add_rvalue_reference
Definition type_traits_generator.h:1413
conditional
Definition type_traits_generator.h:1223
decay
Definition type_traits_generator.h:1305
enable_if
Definition type_traits_generator.h:1254
extent
Definition type_traits_generator.h:1265
integral_constant
Definition type_traits_generator.h:895
is_arithmetic
Definition type_traits_generator.h:1124
is_array
Definition type_traits_generator.h:1154
is_base_of
Definition type_traits_generator.h:1315
is_compound
Definition type_traits_generator.h:1144
is_const
Definition type_traits_generator.h:971
is_floating_point
Definition type_traits_generator.h:1094
is_fundamental
Definition type_traits_generator.h:1134
is_integral
Definition type_traits_generator.h:1064
is_lvalue_reference
Definition type_traits_generator.h:1184
is_rvalue_reference
Definition type_traits_generator.h:1207
is_pointer
Definition type_traits_generator.h:1164
is_reference
Definition type_traits_generator.h:1174
is_same
Definition type_traits_generator.h:1104
is_signed
Definition type_traits_generator.h:1074
is_unsigned
Definition type_traits_generator.h:1084
is_void
Definition type_traits_generator.h:1114
is_volatile
Definition type_traits_generator.h:1001
make_signed
Definition type_traits_generator.h:1234
make_unsigned
Definition type_traits_generator.h:1244
negation
Definition type_traits_generator.h:929
rank
Definition type_traits_generator.h:1295
remove_all_extents
Definition type_traits_generator.h:1285
remove_const
Definition type_traits_generator.h:981
remove_cv
Definition type_traits_generator.h:1031
remove_cvref
Definition type_traits_generator.h:1052
remove_extent
Definition type_traits_generator.h:1275
remove_pointer
Definition type_traits_generator.h:951
remove_reference
Definition type_traits_generator.h:941
remove_volatile
Definition type_traits_generator.h:1011
Is T a member pointer.
Definition type_traits_generator.h:2688
bitset_ext
Definition absolute.h:39
add_lvalue_reference
Definition type_traits_generator.h:1333
Definition type_traits_generator.h:912
exclusive_disjunction
Definition type_traits_generator.h:1505
Definition type_traits_generator.h:2166
is_class
Definition type_traits_generator.h:1324
Definition type_traits_generator.h:2208
Definition type_traits_generator.h:2273
Definition type_traits_generator.h:2259
Definition type_traits_generator.h:2697
Definition type_traits_generator.h:2215
Definition type_traits_generator.h:2223
Definition type_traits_generator.h:2244
Definition type_traits_generator.h:2230
Definition type_traits_generator.h:2251
Definition type_traits_generator.h:2237
Get the Nth base of a recursively inherited type. Requires that the class has defined 'base_type'.
Definition type_traits_generator.h:1631
Definition type_traits_generator.h:2690
Defines one of five signed types that has the same size as T.
Definition type_traits_generator.h:2423
size_of
Definition type_traits_generator.h:1788
Definition type_traits_generator.h:2440
A set of templates to allow related types to be derived.
Definition type_traits_generator.h:1653
Primary template for etl::underlying_type Users must specialise this template for their enumerations.
Definition type_traits_generator.h:2472
Defines one of five unsigned types that has the same size as T.
Definition type_traits_generator.h:2405