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