Embedded Template Library 1.0
Loading...
Searching...
No Matches
type_traits_generator.h
Go to the documentation of this file.
1
2
3/******************************************************************************
4The MIT License(MIT)
5
6Embedded Template Library.
7https://github.com/ETLCPP/etl
8https://www.etlcpp.com
9
10Copyright(c) 2014 John Wellbelove
11
12Permission is hereby granted, free of charge, to any person obtaining a copy
13of this software and associated documentation files(the "Software"), to deal
14in the Software without restriction, including without limitation the rights
15to use, copy, modify, merge, publish, distribute, sublicense, and / or sell
16copies of the Software, and to permit persons to whom the Software is
17furnished to do so, subject to the following conditions :
18
19The above copyright notice and this permission notice shall be included in all
20copies or substantial portions of the Software.
21
22THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
23IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
24FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE
25AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
26LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
27OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
28SOFTWARE.
29******************************************************************************/
30
31/*[[[cog
32import cog
33cog.outl("#if 0")
34]]]*/
35/*[[[end]]]*/
36#error THIS HEADER IS A GENERATOR. DO NOT INCLUDE.
37/*[[[cog
38import cog
39cog.outl("#endif")
40]]]*/
41/*[[[end]]]*/
42
43/*[[[cog
44import cog
45cog.outl("//***************************************************************************")
46cog.outl("// THIS FILE HAS BEEN AUTO GENERATED. DO NOT EDIT THIS FILE.")
47cog.outl("//***************************************************************************")
48]]]*/
49/*[[[end]]]*/
50
51//***************************************************************************
52// To generate to header file, run this at the command line.
53// Note: You will need Python and COG installed.
54//
55// python -m cogapp -d -e -otypes.h -DHandlers=<n> types_generator.h
56// Where <n> is the number of types to support.
57//
58// e.g.
59// To generate handlers for up to 16 types...
60// python -m cogapp -d -e -otype_traits.h -DIsOneOf=16 type_traits_generator.h
61//
62// See generate.bat
63//***************************************************************************
64
65#ifndef ETL_TYPE_TRAITS_INCLUDED
66#define ETL_TYPE_TRAITS_INCLUDED
67
68#include "platform.h"
69#include "nullptr.h"
70#include "static_assert.h"
71
72#include <stddef.h>
73#include <stdint.h>
74
79
80#if ETL_USING_STL && ETL_USING_CPP11
81 #include <type_traits>
82#endif
83
84namespace etl
85{
86#if ETL_USING_CPP11
87 template <typename...>
88 using void_t = void;
89#endif
90
91#if ETL_NOT_USING_STL || ETL_CPP11_NOT_SUPPORTED
92
93 //*****************************************************************************
94 // Traits are defined by the ETL
95 //*****************************************************************************
96
97 //***************************************************************************
99 template <typename T, T VALUE>
100 struct integral_constant
101 {
102 static const T value = VALUE;
103
104 typedef T value_type;
105 typedef integral_constant<T, VALUE> type;
106
107 operator value_type() const
108 {
109 return value;
110 }
111 };
112
114 typedef integral_constant<bool, false> false_type;
115 typedef integral_constant<bool, true> true_type;
116
117 template <typename T, T VALUE>
118 const T integral_constant<T, VALUE>::value;
119
120#if ETL_USING_CPP17
121 template <typename T, T VALUE>
122 inline constexpr T integral_constant_v = etl::integral_constant<T, VALUE>::value;
123#endif
124
125#if ETL_USING_CPP11
126 template <bool B>
127 using bool_constant = integral_constant<bool, B>;
128#else
129 template <bool B>
130 struct bool_constant : etl::integral_constant<bool, B> { };
131#endif
132
133#if ETL_USING_CPP17
134 template <bool B>
135 inline constexpr bool bool_constant_v = bool_constant<B>::value;
136#endif
137
138 //***************************************************************************
140 template <typename T>
141 struct negation : etl::bool_constant<!bool(T::value)>
142 {
143 };
144
145#if ETL_USING_CPP17
146 template <typename T>
147 inline constexpr bool negation_v = negation<T>::value;
148#endif
149
150 //***************************************************************************
152 template <typename T> struct remove_reference { typedef T type; };
153 template <typename T> struct remove_reference<T&> { typedef T type; };
154#if ETL_USING_CPP11
155 template <typename T> struct remove_reference<T&&> { typedef T type; };
156#endif
157
158#if ETL_USING_CPP11
159 template <typename T>
160 using remove_reference_t = typename remove_reference<T>::type;
161#endif
162
163 //***************************************************************************
165 template <typename T> struct remove_pointer { typedef T type; };
166 template <typename T> struct remove_pointer<T*> { typedef T type; };
167 template <typename T> struct remove_pointer<const T*> { typedef const T type; };
168 template <typename T> struct remove_pointer<volatile T*> { typedef volatile T type; };
169 template <typename T> struct remove_pointer<const volatile T*> { typedef const volatile T type; };
170 template <typename T> struct remove_pointer<T* const> { typedef T type; };
171 template <typename T> struct remove_pointer<const T* const> { typedef const T type; };
172 template <typename T> struct remove_pointer<volatile T* const> { typedef volatile T type; };
173 template <typename T> struct remove_pointer<const volatile T* const> { typedef const volatile T type; };
174
175#if ETL_USING_CPP11
176 template <typename T>
177 using remove_pointer_t = typename remove_pointer<T>::type;
178#endif
179
180 //***************************************************************************
182 template <typename T> struct add_pointer { typedef typename remove_reference<T>::type* type; };
183
184#if ETL_USING_CPP11
185 template <typename T>
186 using add_pointer_t = typename add_pointer<T>::type;
187#endif
188
189 //***************************************************************************
191 template <typename T> struct is_const : false_type {};
192 template <typename T> struct is_const<const T> : true_type {};
193 template <typename T> struct is_const<const volatile T> : true_type {};
194
195#if ETL_USING_CPP17
196 template <typename T>
197 inline constexpr bool is_const_v = is_const<T>::value;
198#endif
199
200 //***************************************************************************
202 template <typename T> struct remove_const { typedef T type; };
203 template <typename T> struct remove_const<const T> { typedef T type; };
204
205#if ETL_USING_CPP11
206 template <typename T>
207 using remove_const_t = typename remove_const<T>::type;
208#endif
209
210 //***************************************************************************
212 template <typename T> struct add_const { typedef const T type; };
213 template <typename T> struct add_const<const T> { typedef const T type; };
214
215#if ETL_USING_CPP11
216 template <typename T>
217 using add_const_t = typename add_const<T>::type;
218#endif
219
220 //***************************************************************************
222 template <typename T> struct is_volatile : false_type {};
223 template <typename T> struct is_volatile<volatile T> : true_type {};
224 template <typename T> struct is_volatile<const volatile T> : true_type {};
225
226#if ETL_USING_CPP17
227 template <typename T>
228 inline constexpr bool is_volatile_v = is_volatile<T>::value;
229#endif
230
231 //***************************************************************************
233 template <typename T> struct remove_volatile { typedef T type; };
234 template <typename T> struct remove_volatile<volatile T> { typedef T type; };
235
236#if ETL_USING_CPP11
237 template <typename T>
238 using remove_volatile_t = typename remove_volatile<T>::type;
239#endif
240
241 //***************************************************************************
243 template <typename T> struct add_volatile { typedef volatile T type; };
244 template <typename T> struct add_volatile<volatile T> { typedef volatile T type; };
245
246#if ETL_USING_CPP11
247 template <typename T>
248 using add_volatile_t = typename add_volatile<T>::type;
249#endif
250
251 //***************************************************************************
253 template <typename T> struct remove_cv
254 {
255 typedef typename remove_volatile<typename remove_const<T>::type>::type type;
256 };
257
258#if ETL_USING_CPP11
259 template <typename T>
260 using remove_cv_t = typename remove_cv<T>::type;
261#endif
262
263 //***************************************************************************
265 template <typename T> struct add_cv
266 {
267 typedef typename add_volatile<typename add_const<T>::type>::type type;
268 };
269
270#if ETL_USING_CPP11
271 template <typename T>
272 using add_cv_t = typename add_cv<T>::type;
273#endif
274
275 //***************************************************************************
277 template <typename T> struct remove_cvref
278 {
279 typedef typename remove_cv<typename remove_reference<T>::type>::type type;
280 };
281
282#if ETL_USING_CPP11
283 template <typename T>
284 using remove_cvref_t = typename remove_cvref<T>::type;
285#endif
286
287 //***************************************************************************
289 template <typename T> struct is_integral : false_type {};
290 template <> struct is_integral<bool> : true_type {};
291 template <> struct is_integral<char> : true_type {};
292 template <> struct is_integral<unsigned char> : true_type {};
293 template <> struct is_integral<signed char> : true_type {};
294 template <> struct is_integral<wchar_t> : true_type {};
295 template <> struct is_integral<short> : true_type {};
296 template <> struct is_integral<unsigned short> : true_type {};
297 template <> struct is_integral<int> : true_type {};
298 template <> struct is_integral<unsigned int> : true_type {};
299 template <> struct is_integral<long> : true_type {};
300 template <> struct is_integral<unsigned long> : true_type {};
301 template <> struct is_integral<long long> : true_type {};
302 template <> struct is_integral<unsigned long long> : true_type {};
303 template <typename T> struct is_integral<const T> : is_integral<T> {};
304 template <typename T> struct is_integral<volatile T> : is_integral<T> {};
305 template <typename T> struct is_integral<const volatile T> : is_integral<T> {};
306
307#if ETL_USING_CPP17
308 template <typename T>
309 inline constexpr bool is_integral_v = is_integral<T>::value;
310#endif
311
312 //***************************************************************************
314 template <typename T> struct is_signed : false_type {};
315 template <> struct is_signed<char> : etl::bool_constant<(char(255) < 0)> {};
316 template <> struct is_signed<wchar_t> : public etl::bool_constant<wchar_t(-1) < wchar_t(0)> {};
317 template <> struct is_signed<signed char> : true_type {};
318 template <> struct is_signed<short> : true_type {};
319 template <> struct is_signed<int> : true_type {};
320 template <> struct is_signed<long> : true_type {};
321 template <> struct is_signed<long long> : true_type {};
322 template <> struct is_signed<float> : true_type {};
323 template <> struct is_signed<double> : true_type {};
324 template <> struct is_signed<long double> : true_type {};
325 template <typename T> struct is_signed<const T> : is_signed<T> {};
326 template <typename T> struct is_signed<volatile T> : is_signed<T> {};
327 template <typename T> struct is_signed<const volatile T> : is_signed<T> {};
328
329#if ETL_USING_CPP17
330 template <typename T>
331 inline constexpr bool is_signed_v = is_signed<T>::value;
332#endif
333
334 //***************************************************************************
336 template <typename T> struct is_unsigned : false_type {};
337 template <> struct is_unsigned<bool> : true_type {};
338 template <> struct is_unsigned<char> : etl::bool_constant<(char(255) > 0)> {};
339 template <> struct is_unsigned<unsigned char> : true_type {};
340 template <> struct is_unsigned<wchar_t> : public etl::bool_constant<(wchar_t(-1) > wchar_t(0))> {};
341 template <> struct is_unsigned<unsigned short> : true_type {};
342 template <> struct is_unsigned<unsigned int> : true_type {};
343 template <> struct is_unsigned<unsigned long> : true_type {};
344 template <> struct is_unsigned<unsigned long long> : true_type {};
345 template <typename T> struct is_unsigned<const T> : is_unsigned<T> {};
346 template <typename T> struct is_unsigned<volatile T> : is_unsigned<T> {};
347 template <typename T> struct is_unsigned<const volatile T> : is_unsigned<T> {};
348
349#if ETL_USING_CPP17
350 template <typename T>
351 inline constexpr bool is_unsigned_v = is_unsigned<T>::value;
352#endif
353
354 //***************************************************************************
356 template <typename T> struct is_floating_point : false_type {};
357 template <> struct is_floating_point<float> : true_type {};
358 template <> struct is_floating_point<double> : true_type {};
359 template <> struct is_floating_point<long double> : true_type {};
360 template <typename T> struct is_floating_point<const T> : is_floating_point<T> {};
361 template <typename T> struct is_floating_point<volatile T> : is_floating_point<T> {};
362 template <typename T> struct is_floating_point<const volatile T> : is_floating_point<T> {};
363
364#if ETL_USING_CPP17
365 template <typename T>
366 inline constexpr bool is_floating_point_v = is_floating_point<T>::value;
367#endif
368
369 //***************************************************************************
371 template <typename T1, typename T2> struct is_same : public false_type {};
372 template <typename T> struct is_same<T, T> : public true_type {};
373
374#if ETL_USING_CPP17
375 template <typename T1, typename T2>
376 inline constexpr bool is_same_v = is_same<T1, T2>::value;
377#endif
378
379 //***************************************************************************
381 template<typename T> struct is_void : false_type {};
382 template<> struct is_void<void> : true_type {};
383
384#if ETL_USING_CPP17
385 template <typename T>
386 inline constexpr bool is_void_v = is_void<T>::value;
387#endif
388
389 //***************************************************************************
391 template<typename T> struct is_arithmetic : etl::bool_constant<is_integral<T>::value || is_floating_point<T>::value> {};
392
393#if ETL_USING_CPP17
394 template <typename T>
395 inline constexpr bool is_arithmetic_v = is_arithmetic<T>::value;
396#endif
397
398 //***************************************************************************
400 template <typename T> struct is_fundamental : etl::bool_constant<is_arithmetic<T>::value || is_void<T>::value> {};
401
402#if ETL_USING_CPP17
403 template <typename T>
404 inline constexpr bool is_fundamental_v = is_fundamental<T>::value;
405#endif
406
407 //***************************************************************************
409 template <typename T> struct is_compound : etl::bool_constant<!is_fundamental<T>::value> {};
410
411#if ETL_USING_CPP17
412 template <typename T>
413 inline constexpr bool is_compound_v = is_compound<T>::value;
414#endif
415
416 //***************************************************************************
418 template <typename T> struct is_array : false_type {};
419 template <typename T> struct is_array<T[]> : true_type {};
420 template <typename T, size_t MAXN> struct is_array<T[MAXN]> : true_type {};
421
422#if ETL_USING_CPP17
423 template <typename T>
424 inline constexpr bool is_array_v = is_array<T>::value;
425#endif
426
427 //***************************************************************************
429 template<typename T> struct is_pointer_helper : false_type {};
430 template<typename T> struct is_pointer_helper<T*> : true_type {};
431 template<typename T> struct is_pointer : is_pointer_helper<typename remove_cv<T>::type> {};
432
433#if ETL_USING_CPP17
434 template <typename T>
435 inline constexpr bool is_pointer_v = is_pointer<T>::value;
436#endif
437
438 //***************************************************************************
440 template<typename T> struct is_lvalue_reference_helper : false_type {};
441 template<typename T> struct is_lvalue_reference_helper<T&> : true_type {};
442 template<typename T> struct is_lvalue_reference : is_lvalue_reference_helper<typename remove_cv<T>::type> {};
443
444#if ETL_USING_CPP17
445 template <typename T>
446 inline constexpr bool is_lvalue_reference_v = etl::is_lvalue_reference<T>::value;
447#endif
448
449#if ETL_USING_CPP11
450 //***************************************************************************
452 template<typename T> struct is_rvalue_reference_helper : false_type {};
453 template<typename T> struct is_rvalue_reference_helper<T&&> : true_type {};
454 template<typename T> struct is_rvalue_reference : is_rvalue_reference_helper<typename remove_cv<T>::type> {};
455
456#if ETL_USING_CPP17
457 template <typename T>
458 inline constexpr bool is_rvalue_reference_v = etl::is_rvalue_reference<T>::value;
459#endif
460#endif
461
462 //***************************************************************************
464 // Either lvalue or rvalue (for CPP11)
465 template<typename T> struct is_reference : integral_constant<bool,
466 is_lvalue_reference<T>::value
467 #if ETL_USING_CPP11
468 || is_rvalue_reference<T>::value
469 #endif
470 >{};
471
472#if ETL_USING_CPP17
473 template <typename T>
474 inline constexpr bool is_reference_v = is_reference<T>::value;
475#endif
476
477 //***************************************************************************
480 template <typename T> struct is_pod : etl::bool_constant<etl::is_fundamental<T>::value || etl::is_pointer<T>::value> {};
481
482#if ETL_USING_CPP17
483 template <typename T>
484 inline constexpr bool is_pod_v = etl::is_pod<T>::value;
485#endif
486
487 //***************************************************************************
489 template <bool B, typename T, typename F> struct conditional { typedef T type; };
490 template <typename T, typename F> struct conditional<false, T, F> { typedef F type; };
491
492#if ETL_USING_CPP11
493 template <bool B, typename T, typename F>
494 using conditional_t = typename conditional<B, T, F>::type;
495#endif
496
497 //***************************************************************************
499 template <typename T> struct make_signed { typedef T type; };
500 template <> struct make_signed<char> { typedef signed char type; };
501 template <> struct make_signed<unsigned char> { typedef signed char type; };
502
503 template <> struct make_signed<wchar_t>
504 {
505 typedef etl::conditional<sizeof(wchar_t) == sizeof(int16_t),
506 int16_t,
507 etl::conditional<sizeof(wchar_t) == sizeof(int32_t),
508 int32_t,
509 void>::type>::type type;
510 };
511
512 template <> struct make_signed<unsigned short> { typedef short type; };
513 template <> struct make_signed<unsigned int> { typedef int type; };
514 template <> struct make_signed<unsigned long> { typedef long type; };
515 template <> struct make_signed<unsigned long long> { typedef long long type; };
516 template <typename T> struct make_signed<const T> : add_const<typename make_signed<T>::type> {};
517 template <typename T> struct make_signed<volatile T> : add_volatile<typename make_signed<T>::type> {};
518 template <typename T> struct make_signed<const volatile T> : add_const<typename add_volatile<typename make_signed<T>::type>::type> {};
519
520#if ETL_USING_CPP11
521 template <typename T>
522 using make_signed_t = typename make_signed<T>::type;
523#endif
524
525 //***************************************************************************
527 template <typename T> struct make_unsigned { typedef T type; };
528 template <> struct make_unsigned<char> { typedef unsigned char type; };
529 template <> struct make_unsigned<signed char> { typedef unsigned char type; };
530 template <> struct make_unsigned<short> { typedef unsigned short type; };
531
532 template <> struct make_unsigned<wchar_t>
533 {
534 typedef etl::conditional<sizeof(wchar_t) == sizeof(uint16_t),
535 uint16_t,
536 etl::conditional<sizeof(wchar_t) == sizeof(uint32_t),
537 uint32_t,
538 void>::type>::type type;
539 };
540
541 template <> struct make_unsigned<int> { typedef unsigned int type; };
542 template <> struct make_unsigned<long> { typedef unsigned long type; };
543 template <> struct make_unsigned<long long> { typedef unsigned long long type; };
544 template <typename T> struct make_unsigned<const T> : add_const<typename make_unsigned<T>::type> {};
545 template <typename T> struct make_unsigned<volatile T> : add_volatile<typename make_unsigned<T>::type> {};
546 template <typename T> struct make_unsigned<const volatile T> : add_const<typename add_volatile<typename make_unsigned<T>::type>::type> {};
547
548#if ETL_USING_CPP11
549 template <typename T>
550 using make_unsigned_t = typename make_unsigned<T>::type;
551#endif
552
553 //***************************************************************************
555 template <bool B, typename T = void> struct enable_if {};
556 template <typename T> struct enable_if<true, T> { typedef T type; };
557
558#if ETL_USING_CPP11
559 template <bool B, typename T = void>
560 using enable_if_t = typename enable_if<B, T>::type;
561#endif
562
563 //***************************************************************************
565 template <typename T, unsigned MAXN = 0U>
566 struct extent : integral_constant<size_t, 0U> {};
567
568 template <typename T>
569 struct extent<T[], 0> : integral_constant<size_t, 0U> {};
570
571 template <typename T, unsigned MAXN>
572 struct extent<T[], MAXN> : integral_constant<size_t, extent<T, MAXN - 1>::value> {};
573
574 template <typename T, unsigned MAXN>
575 struct extent<T[MAXN], 0> : integral_constant<size_t, MAXN> {};
576
577 template <typename T, unsigned I, unsigned MAXN>
578 struct extent<T[I], MAXN> : integral_constant<size_t, extent<T, MAXN - 1>::value> {};
579
580#if ETL_USING_CPP17
581 template <typename T, unsigned N = 0U>
582 inline constexpr size_t extent_v = extent<T, N>::value;
583#endif
584
585 //***************************************************************************
587 template <typename T> struct remove_extent { typedef T type; };
588 template <typename T> struct remove_extent<T[]> { typedef T type; };
589 template <typename T, size_t MAXN> struct remove_extent<T[MAXN]> { typedef T type; };
590
591#if ETL_USING_CPP11
592 template <typename T>
593 using remove_extent_t = typename remove_extent<T>::type;
594#endif
595
596 //***************************************************************************
598 template <typename T> struct remove_all_extents { typedef T type; };
599 template <typename T> struct remove_all_extents<T[]> { typedef typename remove_all_extents<T>::type type; };
600 template <typename T, size_t MAXN> struct remove_all_extents<T[MAXN]> { typedef typename remove_all_extents<T>::type type; };
601
602#if ETL_USING_CPP11
603 template <typename T>
604 using remove_all_extents_t = typename remove_all_extents<T>::type;
605#endif
606
607 //***************************************************************************
609 template <typename T>struct rank : integral_constant<size_t, 0> {};
610 template <typename T> struct rank<T[]> : public integral_constant<size_t, rank<T>::value + 1> {};
611 template <typename T, size_t MAXN> struct rank<T[MAXN]> : public integral_constant<size_t, rank<T>::value + 1> {};
612
613#if ETL_USING_CPP17
614 template <typename T>
615 inline constexpr size_t rank_v = rank<T>::value;
616#endif
617
618 //***************************************************************************
620 template <typename T>
621 struct decay
622 {
623 typedef typename etl::remove_reference<T>::type U;
626 typename etl::remove_cv<U>::type>::type type;
627 };
628
629#if ETL_USING_CPP11
630 template <typename T>
631 using decay_t = typename decay<T>::type;
632#endif
633
634 //***************************************************************************
636 template<typename TBase,
637 typename TDerived,
639 struct is_base_of
640 {
641 private:
642 static TBase* check(TBase*) { return (TBase*)0; }
643
644 static char check(...) { return 0; }
645
646 public:
647
648 static const bool value = (sizeof(check((TDerived*)0)) == sizeof(TBase*));
649 };
650
651 // For when TBase or TDerived is a fundamental type.
652 template<typename TBase, typename TDerived>
653 struct is_base_of<TBase, TDerived, true>
654 {
655 static const bool value = false;
656 };
657
658#if ETL_USING_CPP17
659 template <typename T1, typename T2>
660 inline constexpr bool is_base_of_v = is_base_of<T1, T2>::value;
661#endif
662
663 //***************************************************************************
665 namespace private_type_traits
666 {
667 template <typename T> char test(int T::*); // Match for classes.
668
669 struct dummy { char c[2]; };
670 template <typename T> dummy test(...); // Match for non-classes.
671 }
672
673 template <typename T>
674 struct is_class : etl::bool_constant<sizeof(private_type_traits::test<T>(0)) == 1U> {};
675
676#if ETL_USING_CPP17
677 template <typename T>
678 inline constexpr bool is_class_v = is_class<T>::value;
679#endif
680
681 //***************************************************************************
683 template <typename T> struct add_lvalue_reference { typedef T& type; };
684 template <typename T> struct add_lvalue_reference<T&> { typedef T& type; };
685 template <> struct add_lvalue_reference<void> { typedef void type; };
686 template <> struct add_lvalue_reference<const void> { typedef const void type; };
687 template <> struct add_lvalue_reference<volatile void> { typedef volatile void type; };
688 template <> struct add_lvalue_reference<const volatile void> { typedef const volatile void type; };
689
690#if ETL_USING_CPP11
691 template <typename T>
692 using add_lvalue_reference_t = typename etl::add_lvalue_reference<T>::type;
693#endif
694
695 //***************************************************************************
697#if ETL_USING_CPP11
698 template <typename T> struct add_rvalue_reference { using type = T && ; };
699 template <typename T> struct add_rvalue_reference<T&> { using type = T & ; };
700 template <> struct add_rvalue_reference<void> { using type = void; };
701 template <> struct add_rvalue_reference<const void> { using type = const void; };
702 template <> struct add_rvalue_reference<volatile void> { using type = volatile void; };
703 template <> struct add_rvalue_reference<const volatile void> { using type = const volatile void; };
704#endif
705
706#if ETL_USING_CPP11
707 template <typename T>
708 using add_rvalue_reference_t = typename etl::add_rvalue_reference<T>::type;
709#endif
710
711 //***************************************************************************
713#if ETL_USING_CPP11
714 template <typename T>
715 typename etl::add_rvalue_reference<T>::type declval() ETL_NOEXCEPT;
716#endif
717
718#if ETL_USING_CPP11
719 //***************************************************************************
723
724 namespace private_type_traits
725 {
726 // Base case
727 template <typename T, typename = int>
728 struct is_convertible_to_int : false_type
729 {
730 };
731
732 // Selected if `static_cast<int>(declval<T>())` is a valid statement
733 // 2nd template argument of base case defaults to int to ensure that this partial specialization is always tried first
734 template <typename T>
735 struct is_convertible_to_int<T, decltype(static_cast<int>(declval<T>()))>
736 : true_type
737 {
738 };
739 }
740
741 template <typename T>
742 struct is_enum
743 : integral_constant<bool, private_type_traits::is_convertible_to_int<T>::value &&
744 !is_class<T>::value &&
745 !is_arithmetic<T>::value &&
746 !is_reference<T>::value>
747 {
748 };
749
750#if ETL_USING_CPP17
751 template <typename T>
752 inline constexpr bool is_enum_v = etl::is_enum<T>::value;
753#endif
754
755#endif
756
757 //***************************************************************************
759#if ETL_USING_CPP11
760 namespace private_type_traits
761 {
762 template <typename>
764
765 template <typename T>
766 auto returnable(int)->true_type_for<T()>;
767
768 template <typename>
769 auto returnable(...)->etl::false_type;
770
771 template <typename TFrom, typename TTo>
772 auto nonvoid_convertible(int)->true_type_for<decltype(etl::declval<void(&)(TTo)>()(etl::declval<TFrom>()))
773 >;
774 template <typename, typename>
775 auto nonvoid_convertible(...)->etl::false_type;
776 }
777
778#if defined(ETL_COMPILER_ARM5)
779 template <typename TFrom, typename TTo>
780 struct is_convertible : etl::bool_constant<__is_convertible_to(TFrom, TTo)> {};
781#else
782 template <typename TFrom, typename TTo>
783 struct is_convertible : etl::bool_constant<(decltype(private_type_traits::returnable<TTo>(0))::value &&
784 decltype(private_type_traits::nonvoid_convertible<TFrom, TTo>(0))::value) ||
785 (etl::is_void<TFrom>::value && etl::is_void<TTo>::value)> {};
786#endif
787#endif
788
789#if ETL_USING_CPP17
790 template <typename TFrom, typename TTo >
791 inline constexpr bool is_convertible_v = etl::is_convertible<TFrom, TTo>::value;
792#endif
793
794 //***************************************************************************
797#if ETL_USING_CPP11 && !defined(ETL_COMPILER_ARM5)
798 template <typename T> struct alignment_of : integral_constant<size_t, alignof(T)> { };
799#elif defined(ETL_COMPILER_MICROSOFT)
800 template <typename T> struct alignment_of : integral_constant<size_t, size_t(__alignof(T))> {};
801#elif defined(ETL_COMPILER_IAR) || defined(ETL_COMPILER_TI)
802 template <typename T> struct alignment_of : integral_constant<size_t, size_t(__ALIGNOF__(T))> {};
803#else
804 template <typename T> struct alignment_of : integral_constant<size_t, size_t(__alignof__(T))> {};
805#endif
806
809 template <> struct alignment_of<void> : integral_constant <size_t, 0> {};
810 template <> struct alignment_of<const void> : integral_constant <size_t, 0> {};
811
812#if ETL_USING_CPP17
813 template <typename T>
814 inline constexpr size_t alignment_of_v = etl::alignment_of<T>::value;
815#endif
816
817#else // Condition = ETL_USING_STL && ETL_USING_CPP11
818
819//*****************************************************************************
820// Traits are derived from the STL
821//*****************************************************************************
822
823 //***************************************************************************
826 template <typename T, T VALUE>
827 struct integral_constant : std::integral_constant<T, VALUE> {};
828
833
834#if ETL_USING_CPP17
835 template <typename T, T VALUE>
836 inline constexpr T integral_constant_v = std::integral_constant<T, VALUE>::value;
837#endif
838
839#if ETL_USING_CPP17
840 template <bool B>
841 using bool_constant = std::bool_constant<B>;
842#else
843 template <bool B>
844 struct bool_constant : std::integral_constant<bool, B> { };
845#endif
846
847#if ETL_USING_CPP17
848 template <bool B>
849 inline constexpr bool bool_constant_v = bool_constant<B>::value;
850#endif
851
852 //***************************************************************************
855#if ETL_USING_CPP17
856 template <typename T>
857 using negation = std::negation<T>;
858#else
859 template <typename T>
860 struct negation : etl::bool_constant<!bool(T::value)>
861 {
862 };
863#endif
864
865#if ETL_USING_CPP17
866 template <typename T>
867 inline constexpr bool negation_v = std::negation_v<T>;
868#endif
869
870 //***************************************************************************
873 template <typename T> struct remove_reference : std::remove_reference<T> {};
874
875#if ETL_USING_CPP11
876 template <typename T>
877 using remove_reference_t = typename std::remove_reference<T>::type;
878#endif
879
880 //***************************************************************************
883 template <typename T> struct remove_pointer : std::remove_pointer<T> {};
884
885#if ETL_USING_CPP11
886 template <typename T>
887 using remove_pointer_t = typename std::remove_pointer<T>::type;
888#endif
889
890 //***************************************************************************
893 template <typename T> struct add_pointer : std::add_pointer<T> {};
894
895#if ETL_USING_CPP11
896 template <typename T>
897 using add_pointer_t = typename std::add_pointer<T>::type;
898#endif
899
900 //***************************************************************************
903 template <typename T> struct is_const : std::is_const<T> {};
904
905#if ETL_USING_CPP17
906 template <typename T>
907 inline constexpr bool is_const_v = std::is_const_v<T>;
908#endif
909
910 //***************************************************************************
913 template <typename T> struct remove_const : std::remove_const<T> {};
914
915#if ETL_USING_CPP11
916 template <typename T>
917 using remove_const_t = typename std::remove_const<T>::type;
918#endif
919
920 //***************************************************************************
923 template <typename T> struct add_const : std::add_const<T> {};
924
925#if ETL_USING_CPP11
926 template <typename T>
927 using add_const_t = typename std::add_const<T>::type;
928#endif
929
930 //***************************************************************************
933 template <typename T> struct is_volatile : std::is_volatile<T> {};
934
935#if ETL_USING_CPP17
936 template <typename T>
937 inline constexpr bool is_volatile_v = std::is_volatile_v<T>;
938#endif
939
940 //***************************************************************************
943 template <typename T> struct remove_volatile : std::remove_volatile<T> {};
944
945#if ETL_USING_CPP11
946 template <typename T>
947 using remove_volatile_t = typename std::remove_volatile<T>::type;
948#endif
949
950 //***************************************************************************
953 template <typename T> struct add_volatile : std::add_volatile<T> {};
954
955#if ETL_USING_CPP11
956 template <typename T>
957 using add_volatile_t = typename std::add_volatile<T>::type;
958#endif
959
960 //***************************************************************************
963 template <typename T> struct remove_cv : std::remove_cv<T> {};
964
965#if ETL_USING_CPP11
966 template <typename T>
967 using remove_cv_t = typename std::remove_cv<T>::type;
968#endif
969
970 //***************************************************************************
973 template <typename T> struct add_cv : std::add_cv<T> {};
974
975#if ETL_USING_CPP11
976 template <typename T>
977 using add_cv_t = typename std::add_cv<T>::type;
978#endif
979
980 //***************************************************************************
983 template <typename T> struct remove_cvref
984 {
985 typedef typename std::remove_cv<typename std::remove_reference<T>::type>::type type;
986 };
987
988#if ETL_USING_CPP11
989 template <typename T>
990 using remove_cvref_t = typename etl::remove_cvref<T>::type;
991#endif
992
993 //***************************************************************************
996 template <typename T> struct is_integral : std::is_integral<T> {};
997
998#if ETL_USING_CPP17
999 template <typename T>
1000 inline constexpr bool is_integral_v = std::is_integral_v<T>;
1001#endif
1002
1003 //***************************************************************************
1006 template <typename T> struct is_signed : std::is_signed<T> {};
1007
1008#if ETL_USING_CPP17
1009 template <typename T>
1010 inline constexpr bool is_signed_v = std::is_signed_v<T>;
1011#endif
1012
1013 //***************************************************************************
1016 template <typename T> struct is_unsigned : std::is_unsigned<T> {};
1017
1018#if ETL_USING_CPP17
1019 template <typename T>
1020 inline constexpr bool is_unsigned_v = std::is_unsigned_v<T>;
1021#endif
1022
1023 //***************************************************************************
1026 template <typename T> struct is_floating_point : std::is_floating_point<T> {};
1027
1028#if ETL_USING_CPP17
1029 template <typename T>
1030 inline constexpr bool is_floating_point_v = std::is_floating_point_v<T>;
1031#endif
1032
1033 //***************************************************************************
1036 template <typename T1, typename T2> struct is_same : std::is_same<T1, T2> {};
1037
1038#if ETL_USING_CPP17
1039 template <typename T1, typename T2>
1040 inline constexpr bool is_same_v = std::is_same_v<T1, T2>;
1041#endif
1042
1043 //***************************************************************************
1046 template<typename T> struct is_void : std::is_void<T> {};
1047
1048#if ETL_USING_CPP17
1049 template <typename T>
1050 inline constexpr bool is_void_v = std::is_void_v<T>;
1051#endif
1052
1053 //***************************************************************************
1056 template<typename T> struct is_arithmetic : std::is_arithmetic<T> {};
1057
1058#if ETL_USING_CPP17
1059 template <typename T>
1060 inline constexpr bool is_arithmetic_v = std::is_arithmetic_v<T>;
1061#endif
1062
1063 //***************************************************************************
1066 template <typename T> struct is_fundamental : std::is_fundamental<T> {};
1067
1068#if ETL_USING_CPP17
1069 template <typename T>
1070 inline constexpr bool is_fundamental_v = std::is_fundamental_v<T>;
1071#endif
1072
1073 //***************************************************************************
1076 template <typename T> struct is_compound : std::is_compound<T> {};
1077
1078#if ETL_USING_CPP17
1079 template <typename T>
1080 inline constexpr bool is_compound_v = std::is_compound_v<T>;
1081#endif
1082
1083 //***************************************************************************
1086 template <typename T> struct is_array : std::is_array<T> {};
1087
1088#if ETL_USING_CPP17
1089 template <typename T>
1090 inline constexpr bool is_array_v = std::is_array_v<T>;
1091#endif
1092
1093 //***************************************************************************
1096 template<typename T> struct is_pointer : std::is_pointer<T> {};
1097
1098#if ETL_USING_CPP17
1099 template <typename T>
1100 inline constexpr bool is_pointer_v = std::is_pointer_v<T>;
1101#endif
1102
1103 //***************************************************************************
1106 template<typename T> struct is_reference : std::is_reference<T> {};
1107
1108#if ETL_USING_CPP17
1109 template <typename T>
1110 inline constexpr bool is_reference_v = std::is_reference_v<T>;
1111#endif
1112
1113 //***************************************************************************
1116 template<typename T> struct is_lvalue_reference : std::is_lvalue_reference<T> {};
1117
1118#if ETL_USING_CPP17
1119 template <typename T>
1120 inline constexpr bool is_lvalue_reference_v = std::is_lvalue_reference_v<T>;
1121#endif
1122
1123 //***************************************************************************
1126#if ETL_USING_CPP11
1127 template<typename T> struct is_rvalue_reference : std::is_rvalue_reference<T> {};
1128
1129#if ETL_USING_CPP17
1130 template <typename T>
1131 inline constexpr bool is_rvalue_reference_v = std::is_rvalue_reference_v<T>;
1132#endif
1133#endif
1134
1135 //***************************************************************************
1138 template <typename T>
1139 struct is_pod : std::integral_constant<bool, std::is_standard_layout<T>::value && std::is_trivial<T>::value> {};
1140
1141#if ETL_USING_CPP17
1142 template <typename T>
1143 inline constexpr bool is_pod_v = std::is_standard_layout_v<T> && std::is_trivial_v<T>;
1144#endif
1145
1146#if defined(ETL_COMPILER_GCC)
1147 #if ETL_COMPILER_VERSION >= 5
1148 #define ETL_GCC_V5_TYPE_TRAITS_SUPPORTED
1149 #endif
1150#endif
1151
1152 //***************************************************************************
1155 template <bool B, typename T, typename F> struct conditional { typedef T type; };
1156 template <typename T, typename F> struct conditional<false, T, F> { typedef F type; };
1157
1158#if ETL_USING_CPP11
1159 template <bool B, typename T, typename F>
1161#endif
1162
1163 //***************************************************************************
1166 template <typename T> struct make_signed : std::make_signed<T> {};
1167
1168#if ETL_USING_CPP11
1169 template <typename T>
1170 using make_signed_t = typename std::make_signed<T>::type;
1171#endif
1172
1173 //***************************************************************************
1176 template <typename T> struct make_unsigned : std::make_unsigned<T> {};
1177
1178#if ETL_USING_CPP11
1179 template <typename T>
1180 using make_unsigned_t = typename std::make_unsigned<T>::type;
1181#endif
1182
1183 //***************************************************************************
1186 template <bool B, typename T = void> struct enable_if : std::enable_if<B, T> {};
1187
1188#if ETL_USING_CPP11
1189 template <bool B, typename T = void>
1190 using enable_if_t = typename std::enable_if<B, T>::type;
1191#endif
1192
1193 //***************************************************************************
1196 template <typename T, unsigned MAXN = 0U>
1197 struct extent : std::extent<T, MAXN> {};
1198
1199#if ETL_USING_CPP17
1200 template <typename T, unsigned MAXN = 0U>
1201 inline constexpr size_t extent_v = std::extent_v<T, MAXN>;
1202#endif
1203
1204 //***************************************************************************
1207 template <typename T> struct remove_extent : std::remove_extent<T> { };
1208
1209#if ETL_USING_CPP11
1210 template <typename T>
1211 using remove_extent_t = typename std::remove_extent<T>::type;
1212#endif
1213
1214 //***************************************************************************
1217 template <typename T> struct remove_all_extents : std::remove_all_extents<T> { };
1218
1219#if ETL_USING_CPP11
1220 template <typename T>
1221 using remove_all_extents_t = typename std::remove_all_extents<T>::type;
1222#endif
1223
1224 //***************************************************************************
1227 template <typename T>struct rank : std::rank<T> {};
1228
1229#if ETL_USING_CPP17
1230 template <typename T>
1231 inline constexpr size_t rank_v = std::rank_v<T>;
1232#endif
1233
1234 //***************************************************************************
1237 template <typename T> struct decay : std::decay<T> {};
1238
1239#if ETL_USING_CPP11
1240 template <typename T>
1241 using decay_t = typename std::decay<T>::type;
1242#endif
1243
1244 //***************************************************************************
1247 template<typename TBase, typename TDerived> struct is_base_of : std::is_base_of<TBase, TDerived> {};
1248
1249#if ETL_USING_CPP17
1250 template <typename TBase, typename TDerived>
1251 inline constexpr bool is_base_of_v = std::is_base_of_v<TBase, TDerived>;
1252#endif
1253
1254 //***************************************************************************
1256 template <typename T> struct is_class : std::is_class<T>{};
1257
1258#if ETL_USING_CPP17
1259 template <typename T>
1260 inline constexpr bool is_class_v = is_class<T>::value;
1261#endif
1262
1263 //***************************************************************************
1265 template <typename T> struct add_lvalue_reference : std::add_lvalue_reference<T> {};
1266
1267#if ETL_USING_CPP11
1268 template <typename T>
1269 using add_lvalue_reference_t = typename std::add_lvalue_reference<T>::type;
1270#endif
1271
1272 //***************************************************************************
1274#if ETL_USING_CPP11
1275 template <typename T> struct add_rvalue_reference : std::add_rvalue_reference<T> {};
1276#endif
1277
1278#if ETL_USING_CPP11
1279 template <typename T>
1280 using add_rvalue_reference_t = typename std::add_rvalue_reference<T>::type;
1281#endif
1282
1283 //***************************************************************************
1285#if ETL_USING_CPP11
1286 template <typename T>
1287 typename std::add_rvalue_reference<T>::type declval() ETL_NOEXCEPT;
1288#endif
1289
1290#if ETL_USING_CPP11
1291 //***************************************************************************
1294 template <typename T>
1295 struct is_enum : std::is_enum<T>
1296 {
1297 };
1298
1299#if ETL_USING_CPP17
1300 template <typename T>
1301 inline constexpr bool is_enum_v = etl::is_enum<T>::value;
1302#endif
1303
1304#endif
1305
1306 //***************************************************************************
1309#if ETL_USING_CPP11
1310 template <typename TFrom, typename TTo>
1311 struct is_convertible : std::is_convertible<TFrom, TTo> {};
1312#endif
1313
1314#if ETL_USING_CPP17
1315 template <typename TFrom, typename TTo>
1316 inline constexpr bool is_convertible_v = std::is_convertible_v<TFrom, TTo>;
1317#endif
1318
1319 //***************************************************************************
1322 template <typename T> struct alignment_of : std::alignment_of<T> {};
1323 template <> struct alignment_of<void> : std::integral_constant<size_t, 0> {};
1324 template <> struct alignment_of<const void> : std::integral_constant <size_t, 0> {};
1325
1326#if ETL_USING_CPP17
1327 template <typename T>
1328 inline constexpr size_t alignment_of_v = std::alignment_of_v<T>;
1329#endif
1330
1331#endif // Condition = ETL_USING_STL && ETL_USING_CPP11
1332
1333 //***************************************************************************
1334 // ETL extended type traits.
1335 //***************************************************************************
1336
1337 //***************************************************************************
1339 // /\ingroup type_traits
1340 template <bool B, typename T, T TRUE_VALUE, T FALSE_VALUE>
1342
1343 template <typename T, T TRUE_VALUE, T FALSE_VALUE>
1345 {
1346 ETL_STATIC_ASSERT(etl::is_integral<T>::value, "Not an integral type");
1347 static const T value = TRUE_VALUE;
1348 };
1349
1350 template <typename T, T TRUE_VALUE, T FALSE_VALUE>
1352 {
1353 ETL_STATIC_ASSERT(etl::is_integral<T>::value, "Not an integral type");
1354 static const T value = FALSE_VALUE;
1355 };
1356
1357#if ETL_USING_CPP11
1358 //***************************************************************************
1361 template <typename T, typename T1, typename... TRest>
1362 struct is_one_of
1363 {
1364 static const bool value = etl::is_same<T, T1>::value ||
1365 etl::is_one_of<T, TRest...>::value;
1366 };
1367
1368 template <typename T, typename T1>
1369 struct is_one_of<T, T1>
1370 {
1371 static const bool value = etl::is_same<T, T1>::value;
1372 };
1373#else
1374 /*[[[cog
1375 import cog
1376 cog.outl("//***************************************************************************")
1377 cog.outl("/// Template to determine if a type is one of a specified list.")
1378 cog.outl("///\\ingroup types")
1379 cog.outl("template <typename T,")
1380 cog.out(" ")
1381 cog.out("typename T1, ")
1382 for n in range(2, int(IsOneOf)):
1383 cog.out("typename T%s = void, " % n)
1384 if n % 4 == 0:
1385 cog.outl("")
1386 cog.out(" ")
1387 cog.outl("typename T%s = void>" % IsOneOf)
1388 cog.outl("struct is_one_of")
1389 cog.outl("{")
1390 cog.outl(" static const bool value = ")
1391 for n in range(1, int(IsOneOf)):
1392 cog.outl(" etl::is_same<T, T%s>::value ||" % n)
1393 cog.outl(" etl::is_same<T, T%s>::value;" % IsOneOf)
1394 cog.outl("};")
1395 ]]]*/
1396 /*[[[end]]]*/
1397#endif
1398
1399#if ETL_USING_CPP17
1400 template <typename T, typename... TRest>
1401 inline constexpr bool is_one_of_v = etl::is_one_of<T, TRest...>::value;
1402#endif
1403
1404#if ETL_USING_CPP11
1405 //***************************************************************************
1408 template <typename T, typename T1, typename... TRest>
1409 struct is_base_of_all
1410 {
1411 static const bool value = etl::is_base_of<T, T1>::value &&
1412 etl::is_base_of_all<T, TRest...>::value;
1413 };
1414
1415 template <typename T, typename T1>
1416 struct is_base_of_all<T, T1>
1417 {
1418 static const bool value = etl::is_base_of<T, T1>::value;
1419 };
1420#endif
1421
1422#if ETL_USING_CPP17
1423 template <typename T, typename... TRest>
1424 inline constexpr bool is_base_of_all_v = etl::is_base_of_all<T, TRest...>::value;
1425#endif
1426
1427#if ETL_USING_CPP11
1428 //***************************************************************************
1431 template <typename T, typename T1, typename... TRest>
1432 struct is_base_of_any
1433 {
1434 static const bool value = etl::is_base_of<T, T1>::value ||
1435 etl::is_base_of_any<T, TRest...>::value;
1436 };
1437
1438 template <typename T, typename T1>
1439 struct is_base_of_any<T, T1>
1440 {
1441 static const bool value = etl::is_base_of<T, T1>::value;
1442 };
1443#endif
1444
1445#if ETL_USING_CPP17
1446 template <typename T, typename... TRest>
1447 inline constexpr bool is_base_of_any_v = etl::is_base_of_any<T, TRest...>::value;
1448#endif
1449
1450 //***************************************************************************
1453
1454 // Default.
1455 template <typename T>
1456 struct types
1457 {
1458 private:
1459
1461
1462 public:
1463
1464 typedef type_t type;
1465 typedef type_t& reference;
1466 typedef const type_t& const_reference;
1467 typedef type_t* pointer;
1468 typedef const type_t* const_pointer;
1469 typedef const type_t* const const_pointer_const;
1470
1471#if ETL_USING_CPP11
1472 typedef type_t&& rvalue_reference;
1473#endif
1474 };
1475
1476 // Pointers.
1477 template <typename T>
1478 struct types<T*>
1479 {
1480 private:
1481
1483
1484 public:
1485
1486 typedef type_t type;
1487 typedef type_t& reference;
1488 typedef const type_t& const_reference;
1489 typedef type_t* pointer;
1490 typedef const type_t* const_pointer;
1491 typedef const type_t* const const_pointer_const;
1492
1493#if ETL_USING_CPP11
1494 typedef type_t&& rvalue_reference;
1495#endif
1496 };
1497
1498 // Pointers.
1499 template <typename T>
1500 struct types<T* const>
1501 {
1502 private:
1503
1505
1506 public:
1507
1508 typedef type_t type;
1509 typedef type_t& reference;
1510 typedef const type_t& const_reference;
1511 typedef type_t* pointer;
1512 typedef const type_t* const_pointer;
1513 typedef const type_t* const const_pointer_const;
1514
1515#if ETL_USING_CPP11
1516 typedef type_t&& rvalue_reference;
1517#endif
1518 };
1519
1520 // References.
1521 template <typename T>
1522 struct types<T&>
1523 {
1524 private:
1525
1527
1528 public:
1529
1530 typedef type_t type;
1531 typedef type_t& reference;
1532 typedef const type_t& const_reference;
1533 typedef type_t* pointer;
1534 typedef const type_t* const_pointer;
1535 typedef const type_t* const const_pointer_const;
1536
1537#if ETL_USING_CPP11
1538 typedef type_t&& rvalue_reference;
1539#endif
1540 };
1541
1542#if ETL_USING_CPP11
1543 // rvalue References.
1544 template <typename T>
1545 struct types<T&&>
1546 {
1547 private:
1548
1549 typedef typename etl::remove_reference<typename etl::remove_cv<T>::type>::type type_t;
1550
1551 public:
1552
1553 typedef type_t type;
1554 typedef type_t& reference;
1555 typedef const type_t& const_reference;
1556 typedef type_t* pointer;
1557 typedef const type_t* const_pointer;
1558 typedef const type_t* const const_pointer_const;
1559
1560#if ETL_USING_CPP11
1561 typedef type_t&& rvalue_reference;
1562#endif
1563 };
1564#endif
1565
1566#if ETL_USING_CPP11
1567 template <typename T>
1568 using types_t = typename types<T>::type;
1569
1570 template <typename T>
1571 using types_r = typename types<T>::reference;
1572
1573 template <typename T>
1574 using types_cr = typename types<T>::const_reference;
1575
1576 template <typename T>
1577 using types_rr = typename types<T>::rvalue_reference;
1578
1579 template <typename T>
1580 using types_p = typename types<T>::pointer;
1581
1582 template <typename T>
1583 using types_cp = typename types<T>::const_pointer;
1584
1585 template <typename T>
1586 using types_cpc = typename types<T>::const_pointer_const;
1587#endif
1588
1589 //***************************************************************************
1592 template <typename T> struct size_of : etl::integral_constant<size_t, sizeof(T)> {};
1593 template <> struct size_of<void> : etl::integral_constant<size_t, 1U> {};
1594
1595#if ETL_USING_CPP17
1596 template <typename T>
1597 inline constexpr size_t size_of_v = etl::size_of<T>::value;
1598#endif
1599
1600#if ETL_USING_CPP11
1601 //***************************************************************************
1603 template <typename T, typename T1, typename... TRest>
1604 struct are_all_same
1605 {
1606 static const bool value = etl::is_same<T, T1>::value &&
1607 etl::are_all_same<T, TRest...>::value;
1608 };
1609
1610 template <typename T, typename T1>
1611 struct are_all_same<T, T1>
1612 {
1613 static const bool value = etl::is_same<T, T1>::value;
1614 };
1615#endif
1616
1617#if ETL_USING_CPP17
1618 template <typename T, typename T1, typename... TRest>
1619 inline constexpr bool are_all_same_v = are_all_same<T, T1, TRest...>::value;
1620#endif
1621
1622 //***************************************************************************
1624#if ETL_USING_CPP11
1625 template <typename...>
1626 struct conjunction : public etl::true_type
1627 {
1628 };
1629
1630 template <typename T1, typename... Tn>
1631 struct conjunction<T1, Tn...> : public etl::conditional_t<bool(T1::value), etl::conjunction<Tn...>, T1>
1632 {
1633 };
1634
1635 template <typename T>
1636 struct conjunction<T> : public T
1637 {
1638 };
1639#endif
1640
1641#if ETL_USING_CPP17
1642 template <typename... T>
1643 inline constexpr bool conjunction_v = conjunction<T...>::value;
1644#endif
1645
1646 //***************************************************************************
1648#if ETL_USING_CPP11
1649 template <typename...>
1650 struct disjunction : public etl::false_type
1651 {
1652 };
1653
1654 template <typename T1, typename... Tn>
1655 struct disjunction<T1, Tn...> : public etl::conditional_t<bool(T1::value), T1, disjunction<Tn...>>
1656 {
1657 };
1658
1659 template <typename T1> struct disjunction<T1> : public T1
1660 {
1661 };
1662#endif
1663
1664#if ETL_USING_CPP17
1665 template <typename... T>
1666 inline constexpr bool disjunction_v = etl::disjunction<T...>::value;
1667#endif
1668
1669 //***************************************************************************
1670#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))
1671
1672 //*********************************************
1673 // Use the STL's definitions.
1674 //*********************************************
1675
1676 //*********************************************
1677 // is_assignable
1678 template<typename T1, typename T2>
1679 using is_assignable = std::is_assignable<T1, T2>;
1680
1681 //*********************************************
1682 // is_constructible
1683 template<typename T, typename... TArgs>
1684 using is_constructible = std::is_constructible<T, TArgs...>;
1685
1686 //*********************************************
1687 // is_copy_constructible
1688 template <typename T>
1689 using is_copy_constructible = std::is_copy_constructible<T>;
1690
1691 //*********************************************
1692 // is_move_constructible
1693 template <typename T>
1694 using is_move_constructible = std::is_move_constructible<T>;
1695
1696 //*********************************************
1697 // is_trivially_constructible
1698#if ETL_CPP11_TYPE_TRAITS_IS_TRIVIAL_SUPPORTED
1699 template <typename T>
1700 using is_trivially_constructible = std::is_trivially_constructible<T>;
1701#else
1702 template <typename T>
1704#endif
1705
1706 //*********************************************
1707 // is_trivially_copy_constructible
1708#if ETL_CPP11_TYPE_TRAITS_IS_TRIVIAL_SUPPORTED
1709 template <typename T>
1710 using is_trivially_copy_constructible = std::is_trivially_copy_constructible<T>;
1711#else
1712 template <typename T>
1713 using is_trivially_copy_constructible = etl::bool_constant<etl::is_arithmetic<T>::value || etl::is_pointer<T>::value>;
1714#endif
1715
1716 //*********************************************
1717 // is_trivially_destructible
1718#if ETL_CPP11_TYPE_TRAITS_IS_TRIVIAL_SUPPORTED
1719 template <typename T>
1720 using is_trivially_destructible = std::is_trivially_destructible<T>;
1721#else
1722 template <typename T>
1724#endif
1725
1726 //*********************************************
1727 // is_trivially_copy_assignable
1728#if ETL_CPP11_TYPE_TRAITS_IS_TRIVIAL_SUPPORTED
1729 template <typename T>
1730 using is_trivially_copy_assignable = std::is_trivially_copy_assignable<T>;
1731#else
1732 template <typename T>
1733 using is_trivially_copy_assignable = etl::bool_constant<etl::is_arithmetic<T>::value || etl::is_pointer<T>::value>;
1734#endif
1735
1736 //*********************************************
1737 // is_trivially_copyable
1738#if ETL_CPP11_TYPE_TRAITS_IS_TRIVIAL_SUPPORTED
1739 template <typename T>
1740 using is_trivially_copyable = std::is_trivially_copyable<T>;
1741#else
1742 template <typename T>
1744#endif
1745
1746#elif defined(ETL_USE_TYPE_TRAITS_BUILTINS) && !defined(ETL_USER_DEFINED_TYPE_TRAITS)
1747
1748 //*********************************************
1749 // Use the compiler's builtins.
1750 //*********************************************
1751
1752 //*********************************************
1753 // is_assignable
1754 template<typename T1, typename T2>
1755 struct is_assignable
1756 {
1757 static ETL_CONSTANT bool value = __is_assignable(T1, T2);
1758 };
1759
1760#if ETL_USING_CPP11
1761 //*********************************************
1762 // is_constructible
1763 template<typename T, typename... TArgs>
1764 struct is_constructible
1765 {
1766 static ETL_CONSTANT bool value = __is_constructible(T, TArgs...);
1767 };
1768#else
1769 //*********************************************
1770 // is_constructible
1771 template<typename T, typename TArgs = void>
1772 struct is_constructible
1773 {
1774 static ETL_CONSTANT bool value = __is_constructible(T, TArgs);
1775 };
1776
1777 //*********************************************
1778 // is_constructible
1779 template<typename T>
1780 struct is_constructible<T, void>
1781 {
1782 static ETL_CONSTANT bool value = __is_constructible(T);
1783 };
1784#endif
1785
1786 //*********************************************
1787 // is_copy_constructible
1788 template <typename T>
1789 struct is_copy_constructible : public etl::is_constructible<T, typename etl::add_lvalue_reference<const T>::type>
1790 {
1791 };
1792
1793 //*********************************************
1794 // is_move_constructible
1795 template <typename T>
1796 struct is_move_constructible : public etl::is_constructible<T, T>
1797 {
1798 };
1799
1800#if ETL_USING_CPP11
1801 //*********************************************
1802 // is_trivially_constructible
1803 template <typename T, typename... TArgs>
1804 struct is_trivially_constructible
1805 {
1806#if defined(ETL_COMPILER_GCC)
1807 static ETL_CONSTANT bool value = __has_trivial_constructor(T);
1808#else
1809 static ETL_CONSTANT bool value = __is_trivially_constructible(T, TArgs...);
1810#endif
1811 };
1812#else
1813 //*********************************************
1814 // is_trivially_constructible
1815 template <typename T, typename TArgs = void>
1816 struct is_trivially_constructible
1817 {
1818#if defined(ETL_COMPILER_GCC)
1819 static ETL_CONSTANT bool value = __has_trivial_constructor(T);
1820#else
1821 static ETL_CONSTANT bool value = __is_trivially_constructible(T, TArgs);
1822#endif
1823 };
1824
1825 //*********************************************
1826 // is_trivially_constructible
1827 template <typename T>
1828 struct is_trivially_constructible<T, void>
1829 {
1830#if defined(ETL_COMPILER_GCC)
1831 static ETL_CONSTANT bool value = __has_trivial_constructor(T);
1832#else
1833 static ETL_CONSTANT bool value = __is_trivially_constructible(T);
1834#endif
1835 };
1836#endif
1837
1838 //*********************************************
1839 // is_trivially_copy_constructible
1840 template <typename T>
1841 struct is_trivially_copy_constructible : public is_trivially_constructible<T, typename add_lvalue_reference<const T>::type>
1842 {
1843 };
1844
1845 //*********************************************
1846 // is_trivially_destructible
1847 template <typename T>
1848 struct is_trivially_destructible
1849 {
1850#if defined(ETL_COMPILER_GCC)
1851 static ETL_CONSTANT bool value = __has_trivial_destructor(T);
1852#else
1853 static ETL_CONSTANT bool value = __is_trivially_destructible(T);
1854#endif
1855 };
1856
1857 //*********************************************
1858 // is_trivially_copy_assignable
1859 template <typename T>
1860 struct is_trivially_copy_assignable
1861 {
1862#if defined(ETL_COMPILER_GCC)
1863 static ETL_CONSTANT bool value = __has_trivial_copy(T);
1864#else
1865 static ETL_CONSTANT bool value = __is_trivially_copyable(T);
1866#endif
1867 };
1868
1869 //*********************************************
1870 // is_trivially_copyable
1871 template <typename T>
1872 struct is_trivially_copyable
1873 {
1874#if defined(ETL_COMPILER_GCC)
1875 static ETL_CONSTANT bool value = __has_trivial_copy(T);
1876#else
1877 static ETL_CONSTANT bool value = __is_trivially_copyable(T);
1878#endif
1879 };
1880
1881#elif defined(ETL_USER_DEFINED_TYPE_TRAITS) && !defined(ETL_USE_TYPE_TRAITS_BUILTINS)
1882
1883 //*********************************************
1884 // Force the user to provide specialisations for
1885 // anything other than arithmetics and pointers.
1886 //*********************************************
1887
1888 //*********************************************
1889 // is_assignable
1890 template <typename T1,
1891 typename T2,
1893 struct is_assignable;
1894
1895 template <typename T1, typename T2>
1896 struct is_assignable<T1, T2, true> : public etl::true_type
1897 {
1898 };
1899
1900 template <typename T1, typename T2>
1901 struct is_assignable<T1, T2, false>;
1902
1903#if ETL_USING_CPP11
1904 //*********************************************
1905 // is_constructible
1906 template <typename T, bool B, typename... TArgs>
1907 struct is_constructible_helper;
1908
1909 template <typename T, typename... TArgs>
1910 struct is_constructible_helper<T, true, TArgs...> : public etl::true_type
1911 {
1912 };
1913
1914 template <typename T, typename... TArgs>
1915 struct is_constructible_helper<T, false, TArgs...>;
1916
1917 template <typename T, typename... TArgs>
1918 struct is_constructible : public is_constructible_helper<T, etl::is_arithmetic<T>::value || etl::is_pointer<T>::value, TArgs...>
1919 {
1920 };
1921#endif
1922
1923 //*********************************************
1924 // is_copy_constructible
1925 template <typename T, bool B = etl::is_arithmetic<T>::value || etl::is_pointer<T>::value>
1926 struct is_copy_constructible;
1927
1928 template <typename T>
1929 struct is_copy_constructible<T, true> : public etl::true_type
1930 {
1931 };
1932
1933 template <typename T>
1934 struct is_copy_constructible<T, false>;
1935
1936 //*********************************************
1937 // is_move_constructible
1938 template <typename T, bool B = etl::is_arithmetic<T>::value || etl::is_pointer<T>::value>
1939 struct is_move_constructible;
1940
1941 template <typename T>
1942 struct is_move_constructible<T, true> : public etl::true_type
1943 {
1944 };
1945
1946 template <typename T>
1947 struct is_move_constructible<T, false>;
1948
1949 //*********************************************
1950 // is_trivially_constructible
1951 template <typename T, bool B = etl::is_arithmetic<T>::value || etl::is_pointer<T>::value>
1952 struct is_trivially_constructible;
1953
1954 template <typename T>
1955 struct is_trivially_constructible<T, true> : public etl::true_type
1956 {
1957 };
1958
1959 template <typename T>
1960 struct is_trivially_constructible<T, false>;
1961
1962 //*********************************************
1963 // is_trivially_copy_constructible
1964 template <typename T, bool B = etl::is_arithmetic<T>::value || etl::is_pointer<T>::value>
1965 struct is_trivially_copy_constructible;
1966
1967 template <typename T>
1968 struct is_trivially_copy_constructible<T, true> : public etl::true_type
1969 {
1970 };
1971
1972 template <typename T>
1973 struct is_trivially_copy_constructible<T, false>;
1974
1975 //*********************************************
1976 // is_trivially_destructible
1977 template <typename T, bool B = etl::is_arithmetic<T>::value || etl::is_pointer<T>::value>
1978 struct is_trivially_destructible;
1979
1980 template <typename T>
1981 struct is_trivially_destructible<T, true> : public etl::true_type
1982 {
1983 };
1984
1985 template <typename T>
1986 struct is_trivially_destructible<T, false>;
1987
1988 //*********************************************
1989 // is_trivially_copy_assignable
1990 template <typename T, bool B = etl::is_arithmetic<T>::value || etl::is_pointer<T>::value>
1991 struct is_trivially_copy_assignable;
1992
1993 template <typename T>
1994 struct is_trivially_copy_assignable<T, true> : public etl::true_type
1995 {
1996 };
1997
1998 template <typename T>
1999 struct is_trivially_copy_assignable<T, false>;
2000
2001 //*********************************************
2002 // is_trivially_copyable
2003 template <typename T, bool B = etl::is_arithmetic<T>::value || etl::is_pointer<T>::value>
2004 struct is_trivially_copyable;
2005
2006 template <typename T>
2007 struct is_trivially_copyable<T, true> : public etl::true_type
2008 {
2009 };
2010
2011 template <typename T>
2012 struct is_trivially_copyable<T, false>;
2013
2014#else
2015
2016 //*********************************************
2017 // Assume that anything other than arithmetics
2018 // and pointers return false for the traits.
2019 //*********************************************
2020
2021 //*********************************************
2022 // is_assignable
2023 template <typename T1, typename T2>
2024 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)>
2025 {
2026 };
2027
2028#if ETL_USING_CPP11
2029 //***************************************************************************
2031 namespace private_type_traits
2032 {
2033 template <class, class T, class... Args>
2035
2036 template <class T, class... Args>
2037 struct is_constructible_<void_t<decltype(T(etl::declval<Args>()...))>, T, Args...> : etl::true_type {};
2038 }
2039
2040 //*********************************************
2041 // is_constructible
2042 template <class T, class... Args>
2043 using is_constructible = private_type_traits::is_constructible_<void_t<>, T, Args...>;
2044
2045 //*********************************************
2046 // is_copy_constructible
2047 template <class T> struct is_copy_constructible : public is_constructible<T, typename etl::add_lvalue_reference<typename etl::add_const<T>::type>::type>{};
2048 template <> struct is_copy_constructible<void> : public false_type{};
2049 template <> struct is_copy_constructible<void const> : public false_type{};
2050 template <> struct is_copy_constructible<void volatile> : public false_type{};
2051 template <> struct is_copy_constructible<void const volatile> : public false_type{};
2052
2053 //*********************************************
2054 // is_move_constructible
2055 template <typename T> struct is_move_constructible: public is_constructible<T, typename etl::add_rvalue_reference<T>::type>{};
2056 template <> struct is_move_constructible<void> : public false_type{};
2057 template <> struct is_move_constructible<void const> : public false_type{};
2058 template <> struct is_move_constructible<void volatile> : public false_type{};
2059 template <> struct is_move_constructible<void const volatile> : public false_type{};
2060
2061#else
2062
2063 //*********************************************
2064 // is_copy_constructible
2065 template <typename T>
2066 struct is_copy_constructible : public etl::bool_constant<etl::is_arithmetic<T>::value || etl::is_pointer<T>::value>
2067 {
2068 };
2069
2070 //*********************************************
2071 // is_move_constructible
2072 template <typename T>
2073 struct is_move_constructible : public etl::bool_constant<etl::is_arithmetic<T>::value || etl::is_pointer<T>::value>
2074 {
2075 };
2076#endif
2077
2078 //*********************************************
2079 // is_trivially_constructible
2080 template <typename T>
2081 struct is_trivially_constructible : public etl::bool_constant<etl::is_arithmetic<T>::value || etl::is_pointer<T>::value>
2082 {
2083 };
2084
2085 //*********************************************
2086 // is_trivially_copy_constructible
2087 template <typename T>
2088 struct is_trivially_copy_constructible : public etl::bool_constant<etl::is_arithmetic<T>::value || etl::is_pointer<T>::value>
2089 {
2090 };
2091
2092 //*********************************************
2093 // is_trivially_destructible
2094 template <typename T>
2095 struct is_trivially_destructible : public etl::bool_constant<etl::is_arithmetic<T>::value || etl::is_pointer<T>::value>
2096 {
2097 };
2098
2099 //*********************************************
2100 // is_trivially_copy_assignable
2101 template <typename T>
2102 struct is_trivially_copy_assignable : public etl::bool_constant<etl::is_arithmetic<T>::value || etl::is_pointer<T>::value>
2103 {
2104 };
2105
2106 //*********************************************
2107 // is_trivially_copyable
2108 template <typename T>
2109 struct is_trivially_copyable : public etl::bool_constant<etl::is_arithmetic<T>::value || etl::is_pointer<T>::value>
2110 {
2111 };
2112
2113#endif
2114
2115 template <typename T1, typename T2>
2116 struct is_lvalue_assignable : public etl::is_assignable<typename etl::add_lvalue_reference<T1>::type,
2117 typename etl::add_lvalue_reference<typename etl::add_const<T2>::type>::type>
2118 {
2119 };
2120
2121#if ETL_USING_CPP11
2122 //*********************************************
2123 // is_default_constructible
2124 template<typename T, typename = void>
2126
2127 template<typename T>
2128 struct is_default_constructible<T, etl::void_t<decltype(T())>> : etl::true_type { };
2129#else
2130 template <typename T>
2131 struct is_default_constructible : public etl::bool_constant<etl::is_arithmetic<T>::value || etl::is_pointer<T>::value>
2132 {
2133 };
2134#endif
2135
2136#if ETL_USING_CPP17
2137
2138 template <typename T1, typename T2>
2139 inline constexpr bool is_assignable_v = etl::is_assignable<T1, T2>::value;
2140
2141 template <typename T1, typename T2>
2143
2144 template<typename T, typename... TArgs>
2145 inline constexpr bool is_constructible_v = etl::is_constructible<T, TArgs...>::value;
2146
2147 template<typename T, typename... TArgs>
2148 inline constexpr bool is_default_constructible_v = etl::is_default_constructible<T, TArgs...>::value;
2149
2150 template<typename T>
2152
2153 template<typename T>
2155
2156 template <typename T>
2158
2159 template <typename T>
2161
2162 template <typename T>
2164
2165 template <typename T>
2167
2168 template <typename T>
2170
2171#endif
2172
2173#if ETL_USING_CPP11
2174 //*********************************************
2175 // common_type
2176 // Based on the sample implementation detailed on
2177 // https://en.cppreference.com/w/cpp/types/common_type
2178 //*********************************************
2179 //***********************************
2180 // Primary template
2181 template<typename...>
2182 struct common_type
2183 {
2184 };
2185
2186 //***********************************
2187 // One type
2188 template <typename T>
2189 struct common_type<T> : common_type<T, T>
2190 {
2191 };
2192
2193 namespace private_common_type
2194 {
2195 template <typename T1, typename T2>
2196 using conditional_result_t = decltype(false ? declval<T1>() : declval<T2>());
2197
2198 template <typename, typename, typename = void>
2199 struct decay_conditional_result
2200 {
2201 };
2202
2203 template <typename T1, typename T2>
2204 struct decay_conditional_result<T1, T2, void_t<conditional_result_t<T1, T2>>>
2206 {
2207 };
2208
2209 template <typename T1, typename T2, typename = void>
2210 struct common_type_2_impl : decay_conditional_result<const T1&, const T2&>
2211 {
2212 };
2213
2214 template <typename T1, typename T2>
2215 struct common_type_2_impl<T1, T2, void_t<conditional_result_t<T1, T2>>>
2216 : decay_conditional_result<T1, T2>
2217 {
2218 };
2219 }
2220
2221 //***********************************
2222 // Two types
2223 template <typename T1, typename T2>
2224 struct common_type<T1, T2>
2225 : etl::conditional<etl::is_same<T1, typename etl::decay<T1>::type>::value&& etl::is_same<T2, typename etl::decay<T2>::type>::value,
2226 private_common_type::common_type_2_impl<T1, T2>,
2227 common_type<typename etl::decay<T2>::type,
2228 typename etl::decay<T2>::type>>::type
2229 {
2230 };
2231
2232 //***********************************
2233 // Three or more types
2234 namespace private_common_type
2235 {
2236 template <typename AlwaysVoid, typename T1, typename T2, typename... TRest>
2238 {
2239 };
2240
2241 template <typename T1, typename T2, typename... TRest>
2243 : common_type<typename common_type<T1, T2>::type, TRest...>
2244 {
2245 };
2246 }
2247
2248 template<typename T1, typename T2, typename... TRest>
2249 struct common_type<T1, T2, TRest...>
2250 : private_common_type::common_type_multi_impl<void, T1, T2, TRest...>
2251 {
2252 };
2253
2254 template <typename... T>
2255 using common_type_t = typename common_type<T...>::type;
2256#endif
2257
2258 //***************************************************************************
2260 //***************************************************************************
2261 template <typename T>
2263 {
2264 typedef typename etl::conditional<sizeof(T) == sizeof(unsigned char), unsigned char,
2265 typename etl::conditional<sizeof(T) == sizeof(unsigned short), unsigned short,
2266 typename etl::conditional<sizeof(T) == sizeof(unsigned int), unsigned int,
2267 typename etl::conditional<sizeof(T) == sizeof(unsigned long), unsigned long,
2268 unsigned long long>::type>::type>::type>::type type;
2269 };
2270
2271#if ETL_USING_CPP11
2272 template <typename T>
2273 using unsigned_type_t = typename unsigned_type<T>::type;
2274#endif
2275
2276 //***************************************************************************
2278 //***************************************************************************
2279 template <typename T>
2281 {
2282 typedef typename etl::conditional<sizeof(T) == sizeof(char), char,
2283 typename etl::conditional<sizeof(T) == sizeof(short), short,
2284 typename etl::conditional<sizeof(T) == sizeof(int), int,
2285 typename etl::conditional<sizeof(T) == sizeof(long), long,
2286 long long>::type>::type>::type>::type type;
2287 };
2288
2289#if ETL_USING_CPP11
2290 template <typename T>
2291 using signed_type_t = typename signed_type<T>::type;
2292#endif
2293
2294 //*********************************************
2295 // type_identity
2296
2297 template <typename T>
2298 struct type_identity { typedef T type; };
2299
2300#if ETL_USING_CPP11
2301 template <typename T>
2302 using type_identity_t = typename type_identity<T>::type;
2303#endif
2304
2305#if ETL_USING_CPP11
2306 //*********************************************
2307 // has_duplicates
2308 template <typename... TTypes>
2309 struct has_duplicates;
2310
2311 template <typename TFirst, typename... TRest>
2312 struct has_duplicates<TFirst, TRest...> : etl::conditional_t<etl::is_one_of<TFirst, TRest...>::value,
2313 etl::true_type,
2314 has_duplicates<TRest...>> {};
2315
2316 template <typename T>
2317 struct has_duplicates<T> : etl::false_type {};
2318
2319 template <>
2320 struct has_duplicates<> : etl::false_type {};
2321#endif
2322
2323#if ETL_USING_CPP17
2324 template <typename... TTypes>
2325 inline constexpr bool has_duplicates_v = etl::has_duplicates<TTypes...>::value;
2326#endif
2327
2328#if ETL_USING_CPP11
2329 //*********************************************
2330 // count_of
2331 template <typename T, typename... TTypes>
2332 struct count_of;
2333
2334 template <typename T, typename U, typename... URest>
2335 struct count_of<T, U, URest...> : etl::integral_constant<size_t,
2336 etl::is_same<T, U>::value +
2337 count_of<T, URest...>::value> {};
2338
2339 template <typename T>
2340 struct count_of<T> : etl::integral_constant<size_t, 0> {};
2341#endif
2342
2343#if ETL_USING_CPP17
2344 template <typename T, typename... TTypes>
2345 inline constexpr size_t count_of_v = etl::count_of<T, TTypes...>::value;
2346#endif
2347
2348#if ETL_USING_CPP11
2349 //*********************************************
2350 // has_duplicates_of
2351 template <typename T, typename... TTypes>
2352 struct has_duplicates_of : etl::bool_constant<(etl::count_of<T, TTypes...>::value > 1U)> {};
2353#endif
2354
2355#if ETL_USING_CPP17
2356 template <typename T, typename... TTypes>
2357 inline constexpr bool has_duplicates_of_v = etl::has_duplicates_of<T, TTypes...>::value;
2358#endif
2359}
2360
2361// Helper macros
2362#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)
2363#define ETL_IS_NOT_CHAR_TYPE(type) (!ETL_IS_CHAR_TYPE(type))
2364
2365#define ETL_IS_POINTER_TYPE(type) (etl::is_pointer<type>::value)
2366#define ETL_IS_NOT_POINTER_TYPE(type) (!ETL_IS_POINTER_TYPE(type))
2367
2368#define ETL_TARGET_IS_TRIVIALLY_COPYABLE(type) (etl::is_trivially_copyable<typename etl::iterator_traits<type>::value_type>::value)
2369#define ETL_TARGET_IS_NOT_TRIVIALLY_COPYABLE(type) (!ETL_TARGET_IS_TRIVIALLY_COPYABLE(type))
2370
2371#endif // ETL_TYPE_TRAITS_INCLUDED
integral_constant< bool, false > false_type
integral_constant specialisations
Definition type_traits_generator.h:831
add_const
Definition type_traits_generator.h:923
add_cv
Definition type_traits_generator.h:973
add_pointer
Definition type_traits_generator.h:893
add_volatile
Definition type_traits_generator.h:953
add_rvalue_reference
Definition type_traits_generator.h:1322
conditional
Definition type_traits_generator.h:1155
decay
Definition type_traits_generator.h:1237
enable_if
Definition type_traits_generator.h:1186
extent
Definition type_traits_generator.h:1197
integral_constant
Definition type_traits_generator.h:827
is_arithmetic
Definition type_traits_generator.h:1056
is_array
Definition type_traits_generator.h:1086
is_base_of
Definition type_traits_generator.h:1247
is_compound
Definition type_traits_generator.h:1076
is_const
Definition type_traits_generator.h:903
is_floating_point
Definition type_traits_generator.h:1026
is_fundamental
Definition type_traits_generator.h:1066
is_integral
Definition type_traits_generator.h:996
is_lvalue_reference
Definition type_traits_generator.h:1116
is_rvalue_reference
Definition type_traits_generator.h:1139
is_pointer
Definition type_traits_generator.h:1096
is_reference
Definition type_traits_generator.h:1106
is_same
Definition type_traits_generator.h:1036
is_signed
Definition type_traits_generator.h:1006
is_unsigned
Definition type_traits_generator.h:1016
is_void
Definition type_traits_generator.h:1046
is_volatile
Definition type_traits_generator.h:933
make_signed
Definition type_traits_generator.h:1166
make_unsigned
Definition type_traits_generator.h:1176
negation
Definition type_traits_generator.h:861
rank
Definition type_traits_generator.h:1227
remove_all_extents
Definition type_traits_generator.h:1217
remove_const
Definition type_traits_generator.h:913
remove_cv
Definition type_traits_generator.h:963
remove_cvref
Definition type_traits_generator.h:984
remove_extent
Definition type_traits_generator.h:1207
remove_pointer
Definition type_traits_generator.h:883
remove_reference
Definition type_traits_generator.h:873
remove_volatile
Definition type_traits_generator.h:943
bitset_ext
Definition absolute.h:38
add_lvalue_reference
Definition type_traits_generator.h:1265
Definition type_traits_generator.h:844
conditional_integral_constant
Definition type_traits_generator.h:1341
conjunction
Definition type_traits_generator.h:2025
is_class
Definition type_traits_generator.h:1256
Definition type_traits_generator.h:2067
Definition type_traits_generator.h:2132
Definition type_traits_generator.h:2118
Definition type_traits_generator.h:2074
Definition type_traits_generator.h:2082
Definition type_traits_generator.h:2103
Definition type_traits_generator.h:2089
Definition type_traits_generator.h:2110
Definition type_traits_generator.h:2096
pair holds two objects of arbitrary type
Definition utility.h:164
ETL_CONSTEXPR pair()
Default constructor.
Definition utility.h:176
Defines one of five signed types that has the same size as T.
Definition type_traits_generator.h:2281
size_of
Definition type_traits_generator.h:1592
Definition type_traits_generator.h:2298
A set of templates to allow related types to be derived.
Definition type_traits_generator.h:1457
Defines one of five unsigned types that has the same size as T.
Definition type_traits_generator.h:2263
void add_pointer(const volatile void *value, TIString &str, const etl::basic_format_spec< TIString > &format, const bool append)
Helper function for pointers.
Definition to_string_helper.h:443