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
643 template<typename T> struct dummy {};
644 struct internal: TDerived, dummy<int>{};
645
646 static TBase* check(TBase*) { return (TBase*)0; }
647
648 template<typename T>
649 static char check(dummy<T>*) { return 0; }
650
651 public:
652
653 static const bool value = (sizeof(check((internal*)0)) == sizeof(TBase*));
654 };
655
656 // For when TBase or TDerived is a fundamental type.
657 template<typename TBase, typename TDerived>
658 struct is_base_of<TBase, TDerived, true>
659 {
660 static const bool value = false;
661 };
662
663#if ETL_USING_CPP17
664 template <typename T1, typename T2>
665 inline constexpr bool is_base_of_v = is_base_of<T1, T2>::value;
666#endif
667
668 //***************************************************************************
670 namespace private_type_traits
671 {
672 template <typename T> char test(int T::*); // Match for classes.
673
674 struct dummy { char c[2]; };
675 template <typename T> dummy test(...); // Match for non-classes.
676 }
677
678 template <typename T>
679 struct is_class : etl::bool_constant<sizeof(private_type_traits::test<T>(0)) == 1U> {};
680
681#if ETL_USING_CPP17
682 template <typename T>
683 inline constexpr bool is_class_v = is_class<T>::value;
684#endif
685
686 //***************************************************************************
688 template <typename T> struct add_lvalue_reference { typedef T& type; };
689 template <typename T> struct add_lvalue_reference<T&> { typedef T& type; };
690 template <> struct add_lvalue_reference<void> { typedef void type; };
691 template <> struct add_lvalue_reference<const void> { typedef const void type; };
692 template <> struct add_lvalue_reference<volatile void> { typedef volatile void type; };
693 template <> struct add_lvalue_reference<const volatile void> { typedef const volatile void type; };
694
695#if ETL_USING_CPP11
696 template <typename T>
697 using add_lvalue_reference_t = typename etl::add_lvalue_reference<T>::type;
698#endif
699
700 //***************************************************************************
702#if ETL_USING_CPP11
703 template <typename T> struct add_rvalue_reference { using type = T && ; };
704 template <typename T> struct add_rvalue_reference<T&> { using type = T & ; };
705 template <> struct add_rvalue_reference<void> { using type = void; };
706 template <> struct add_rvalue_reference<const void> { using type = const void; };
707 template <> struct add_rvalue_reference<volatile void> { using type = volatile void; };
708 template <> struct add_rvalue_reference<const volatile void> { using type = const volatile void; };
709#endif
710
711#if ETL_USING_CPP11
712 template <typename T>
713 using add_rvalue_reference_t = typename etl::add_rvalue_reference<T>::type;
714#endif
715
716 //***************************************************************************
718#if ETL_USING_CPP11
719 template <typename T>
720 typename etl::add_rvalue_reference<T>::type declval() ETL_NOEXCEPT;
721#endif
722
723#if ETL_USING_CPP11
724 //***************************************************************************
728
729 namespace private_type_traits
730 {
731 // Base case
732 template <typename T, typename = int>
733 struct is_convertible_to_int : false_type
734 {
735 };
736
737 // Selected if `static_cast<int>(declval<T>())` is a valid statement
738 // 2nd template argument of base case defaults to int to ensure that this partial specialization is always tried first
739 template <typename T>
740 struct is_convertible_to_int<T, decltype(static_cast<int>(declval<T>()))>
741 : true_type
742 {
743 };
744 }
745
746 template <typename T>
747 struct is_enum
748 : integral_constant<bool, private_type_traits::is_convertible_to_int<T>::value &&
749 !is_class<T>::value &&
750 !is_arithmetic<T>::value &&
751 !is_reference<T>::value>
752 {
753 };
754
755#if ETL_USING_CPP17
756 template <typename T>
757 inline constexpr bool is_enum_v = etl::is_enum<T>::value;
758#endif
759
760#endif
761
762 //***************************************************************************
764#if ETL_USING_CPP11
765 namespace private_type_traits
766 {
767 template <typename>
769
770 template <typename T>
771 auto returnable(int)->true_type_for<T()>;
772
773 template <typename>
774 auto returnable(...)->etl::false_type;
775
776 template <typename TFrom, typename TTo>
777 auto nonvoid_convertible(int)->true_type_for<decltype(etl::declval<void(&)(TTo)>()(etl::declval<TFrom>()))
778 >;
779 template <typename, typename>
780 auto nonvoid_convertible(...)->etl::false_type;
781 }
782
783#if defined(ETL_COMPILER_ARM5)
784 template <typename TFrom, typename TTo>
785 struct is_convertible : etl::bool_constant<__is_convertible_to(TFrom, TTo)> {};
786#else
787 template <typename TFrom, typename TTo>
788 struct is_convertible : etl::bool_constant<(decltype(private_type_traits::returnable<TTo>(0))::value &&
789 decltype(private_type_traits::nonvoid_convertible<TFrom, TTo>(0))::value) ||
790 (etl::is_void<TFrom>::value && etl::is_void<TTo>::value)> {};
791#endif
792#endif
793
794#if ETL_USING_CPP17
795 template <typename TFrom, typename TTo >
796 inline constexpr bool is_convertible_v = etl::is_convertible<TFrom, TTo>::value;
797#endif
798
799 //***************************************************************************
802#if ETL_USING_CPP11 && !defined(ETL_COMPILER_ARM5)
803 template <typename T> struct alignment_of : integral_constant<size_t, alignof(T)> { };
804#elif defined(ETL_COMPILER_MICROSOFT)
805 template <typename T> struct alignment_of : integral_constant<size_t, size_t(__alignof(T))> {};
806#elif defined(ETL_COMPILER_IAR) || defined(ETL_COMPILER_TI)
807 template <typename T> struct alignment_of : integral_constant<size_t, size_t(__ALIGNOF__(T))> {};
808#else
809 template <typename T> struct alignment_of : integral_constant<size_t, size_t(__alignof__(T))> {};
810#endif
811
814 template <> struct alignment_of<void> : integral_constant <size_t, 0> {};
815 template <> struct alignment_of<const void> : integral_constant <size_t, 0> {};
816
817#if ETL_USING_CPP17
818 template <typename T>
819 inline constexpr size_t alignment_of_v = etl::alignment_of<T>::value;
820#endif
821
822#else // Condition = ETL_USING_STL && ETL_USING_CPP11
823
824//*****************************************************************************
825// Traits are derived from the STL
826//*****************************************************************************
827
828 //***************************************************************************
831 template <typename T, T VALUE>
832 struct integral_constant : std::integral_constant<T, VALUE> {};
833
838
839#if ETL_USING_CPP17
840 template <typename T, T VALUE>
841 inline constexpr T integral_constant_v = std::integral_constant<T, VALUE>::value;
842#endif
843
844#if ETL_USING_CPP17
845 template <bool B>
846 using bool_constant = std::bool_constant<B>;
847#else
848 template <bool B>
849 struct bool_constant : std::integral_constant<bool, B> { };
850#endif
851
852#if ETL_USING_CPP17
853 template <bool B>
854 inline constexpr bool bool_constant_v = bool_constant<B>::value;
855#endif
856
857 //***************************************************************************
860#if ETL_USING_CPP17
861 template <typename T>
862 using negation = std::negation<T>;
863#else
864 template <typename T>
865 struct negation : etl::bool_constant<!bool(T::value)>
866 {
867 };
868#endif
869
870#if ETL_USING_CPP17
871 template <typename T>
872 inline constexpr bool negation_v = std::negation_v<T>;
873#endif
874
875 //***************************************************************************
878 template <typename T> struct remove_reference : std::remove_reference<T> {};
879
880#if ETL_USING_CPP11
881 template <typename T>
882 using remove_reference_t = typename std::remove_reference<T>::type;
883#endif
884
885 //***************************************************************************
888 template <typename T> struct remove_pointer : std::remove_pointer<T> {};
889
890#if ETL_USING_CPP11
891 template <typename T>
892 using remove_pointer_t = typename std::remove_pointer<T>::type;
893#endif
894
895 //***************************************************************************
898 template <typename T> struct add_pointer : std::add_pointer<T> {};
899
900#if ETL_USING_CPP11
901 template <typename T>
902 using add_pointer_t = typename std::add_pointer<T>::type;
903#endif
904
905 //***************************************************************************
908 template <typename T> struct is_const : std::is_const<T> {};
909
910#if ETL_USING_CPP17
911 template <typename T>
912 inline constexpr bool is_const_v = std::is_const_v<T>;
913#endif
914
915 //***************************************************************************
918 template <typename T> struct remove_const : std::remove_const<T> {};
919
920#if ETL_USING_CPP11
921 template <typename T>
922 using remove_const_t = typename std::remove_const<T>::type;
923#endif
924
925 //***************************************************************************
928 template <typename T> struct add_const : std::add_const<T> {};
929
930#if ETL_USING_CPP11
931 template <typename T>
932 using add_const_t = typename std::add_const<T>::type;
933#endif
934
935 //***************************************************************************
938 template <typename T> struct is_volatile : std::is_volatile<T> {};
939
940#if ETL_USING_CPP17
941 template <typename T>
942 inline constexpr bool is_volatile_v = std::is_volatile_v<T>;
943#endif
944
945 //***************************************************************************
948 template <typename T> struct remove_volatile : std::remove_volatile<T> {};
949
950#if ETL_USING_CPP11
951 template <typename T>
952 using remove_volatile_t = typename std::remove_volatile<T>::type;
953#endif
954
955 //***************************************************************************
958 template <typename T> struct add_volatile : std::add_volatile<T> {};
959
960#if ETL_USING_CPP11
961 template <typename T>
962 using add_volatile_t = typename std::add_volatile<T>::type;
963#endif
964
965 //***************************************************************************
968 template <typename T> struct remove_cv : std::remove_cv<T> {};
969
970#if ETL_USING_CPP11
971 template <typename T>
972 using remove_cv_t = typename std::remove_cv<T>::type;
973#endif
974
975 //***************************************************************************
978 template <typename T> struct add_cv : std::add_cv<T> {};
979
980#if ETL_USING_CPP11
981 template <typename T>
982 using add_cv_t = typename std::add_cv<T>::type;
983#endif
984
985 //***************************************************************************
988 template <typename T> struct remove_cvref
989 {
990 typedef typename std::remove_cv<typename std::remove_reference<T>::type>::type type;
991 };
992
993#if ETL_USING_CPP11
994 template <typename T>
995 using remove_cvref_t = typename etl::remove_cvref<T>::type;
996#endif
997
998 //***************************************************************************
1001 template <typename T> struct is_integral : std::is_integral<T> {};
1002
1003#if ETL_USING_CPP17
1004 template <typename T>
1005 inline constexpr bool is_integral_v = std::is_integral_v<T>;
1006#endif
1007
1008 //***************************************************************************
1011 template <typename T> struct is_signed : std::is_signed<T> {};
1012
1013#if ETL_USING_CPP17
1014 template <typename T>
1015 inline constexpr bool is_signed_v = std::is_signed_v<T>;
1016#endif
1017
1018 //***************************************************************************
1021 template <typename T> struct is_unsigned : std::is_unsigned<T> {};
1022
1023#if ETL_USING_CPP17
1024 template <typename T>
1025 inline constexpr bool is_unsigned_v = std::is_unsigned_v<T>;
1026#endif
1027
1028 //***************************************************************************
1031 template <typename T> struct is_floating_point : std::is_floating_point<T> {};
1032
1033#if ETL_USING_CPP17
1034 template <typename T>
1035 inline constexpr bool is_floating_point_v = std::is_floating_point_v<T>;
1036#endif
1037
1038 //***************************************************************************
1041 template <typename T1, typename T2> struct is_same : std::is_same<T1, T2> {};
1042
1043#if ETL_USING_CPP17
1044 template <typename T1, typename T2>
1045 inline constexpr bool is_same_v = std::is_same_v<T1, T2>;
1046#endif
1047
1048 //***************************************************************************
1051 template<typename T> struct is_void : std::is_void<T> {};
1052
1053#if ETL_USING_CPP17
1054 template <typename T>
1055 inline constexpr bool is_void_v = std::is_void_v<T>;
1056#endif
1057
1058 //***************************************************************************
1061 template<typename T> struct is_arithmetic : std::is_arithmetic<T> {};
1062
1063#if ETL_USING_CPP17
1064 template <typename T>
1065 inline constexpr bool is_arithmetic_v = std::is_arithmetic_v<T>;
1066#endif
1067
1068 //***************************************************************************
1071 template <typename T> struct is_fundamental : std::is_fundamental<T> {};
1072
1073#if ETL_USING_CPP17
1074 template <typename T>
1075 inline constexpr bool is_fundamental_v = std::is_fundamental_v<T>;
1076#endif
1077
1078 //***************************************************************************
1081 template <typename T> struct is_compound : std::is_compound<T> {};
1082
1083#if ETL_USING_CPP17
1084 template <typename T>
1085 inline constexpr bool is_compound_v = std::is_compound_v<T>;
1086#endif
1087
1088 //***************************************************************************
1091 template <typename T> struct is_array : std::is_array<T> {};
1092
1093#if ETL_USING_CPP17
1094 template <typename T>
1095 inline constexpr bool is_array_v = std::is_array_v<T>;
1096#endif
1097
1098 //***************************************************************************
1101 template<typename T> struct is_pointer : std::is_pointer<T> {};
1102
1103#if ETL_USING_CPP17
1104 template <typename T>
1105 inline constexpr bool is_pointer_v = std::is_pointer_v<T>;
1106#endif
1107
1108 //***************************************************************************
1111 template<typename T> struct is_reference : std::is_reference<T> {};
1112
1113#if ETL_USING_CPP17
1114 template <typename T>
1115 inline constexpr bool is_reference_v = std::is_reference_v<T>;
1116#endif
1117
1118 //***************************************************************************
1121 template<typename T> struct is_lvalue_reference : std::is_lvalue_reference<T> {};
1122
1123#if ETL_USING_CPP17
1124 template <typename T>
1125 inline constexpr bool is_lvalue_reference_v = std::is_lvalue_reference_v<T>;
1126#endif
1127
1128 //***************************************************************************
1131#if ETL_USING_CPP11
1132 template<typename T> struct is_rvalue_reference : std::is_rvalue_reference<T> {};
1133
1134#if ETL_USING_CPP17
1135 template <typename T>
1136 inline constexpr bool is_rvalue_reference_v = std::is_rvalue_reference_v<T>;
1137#endif
1138#endif
1139
1140 //***************************************************************************
1143 template <typename T>
1144 struct is_pod : std::integral_constant<bool, std::is_standard_layout<T>::value && std::is_trivial<T>::value> {};
1145
1146#if ETL_USING_CPP17
1147 template <typename T>
1148 inline constexpr bool is_pod_v = std::is_standard_layout_v<T> && std::is_trivial_v<T>;
1149#endif
1150
1151#if defined(ETL_COMPILER_GCC)
1152 #if ETL_COMPILER_VERSION >= 5
1153 #define ETL_GCC_V5_TYPE_TRAITS_SUPPORTED
1154 #endif
1155#endif
1156
1157 //***************************************************************************
1160 template <bool B, typename T, typename F> struct conditional { typedef T type; };
1161 template <typename T, typename F> struct conditional<false, T, F> { typedef F type; };
1162
1163#if ETL_USING_CPP11
1164 template <bool B, typename T, typename F>
1166#endif
1167
1168 //***************************************************************************
1171 template <typename T> struct make_signed : std::make_signed<T> {};
1172
1173#if ETL_USING_CPP11
1174 template <typename T>
1175 using make_signed_t = typename std::make_signed<T>::type;
1176#endif
1177
1178 //***************************************************************************
1181 template <typename T> struct make_unsigned : std::make_unsigned<T> {};
1182
1183#if ETL_USING_CPP11
1184 template <typename T>
1185 using make_unsigned_t = typename std::make_unsigned<T>::type;
1186#endif
1187
1188 //***************************************************************************
1191 template <bool B, typename T = void> struct enable_if : std::enable_if<B, T> {};
1192
1193#if ETL_USING_CPP11
1194 template <bool B, typename T = void>
1195 using enable_if_t = typename std::enable_if<B, T>::type;
1196#endif
1197
1198 //***************************************************************************
1201 template <typename T, unsigned MAXN = 0U>
1202 struct extent : std::extent<T, MAXN> {};
1203
1204#if ETL_USING_CPP17
1205 template <typename T, unsigned MAXN = 0U>
1206 inline constexpr size_t extent_v = std::extent_v<T, MAXN>;
1207#endif
1208
1209 //***************************************************************************
1212 template <typename T> struct remove_extent : std::remove_extent<T> { };
1213
1214#if ETL_USING_CPP11
1215 template <typename T>
1216 using remove_extent_t = typename std::remove_extent<T>::type;
1217#endif
1218
1219 //***************************************************************************
1222 template <typename T> struct remove_all_extents : std::remove_all_extents<T> { };
1223
1224#if ETL_USING_CPP11
1225 template <typename T>
1226 using remove_all_extents_t = typename std::remove_all_extents<T>::type;
1227#endif
1228
1229 //***************************************************************************
1232 template <typename T>struct rank : std::rank<T> {};
1233
1234#if ETL_USING_CPP17
1235 template <typename T>
1236 inline constexpr size_t rank_v = std::rank_v<T>;
1237#endif
1238
1239 //***************************************************************************
1242 template <typename T> struct decay : std::decay<T> {};
1243
1244#if ETL_USING_CPP11
1245 template <typename T>
1246 using decay_t = typename std::decay<T>::type;
1247#endif
1248
1249 //***************************************************************************
1252 template<typename TBase, typename TDerived> struct is_base_of : std::is_base_of<TBase, TDerived> {};
1253
1254#if ETL_USING_CPP17
1255 template <typename TBase, typename TDerived>
1256 inline constexpr bool is_base_of_v = std::is_base_of_v<TBase, TDerived>;
1257#endif
1258
1259 //***************************************************************************
1261 template <typename T> struct is_class : std::is_class<T>{};
1262
1263#if ETL_USING_CPP17
1264 template <typename T>
1265 inline constexpr bool is_class_v = is_class<T>::value;
1266#endif
1267
1268 //***************************************************************************
1270 template <typename T> struct add_lvalue_reference : std::add_lvalue_reference<T> {};
1271
1272#if ETL_USING_CPP11
1273 template <typename T>
1274 using add_lvalue_reference_t = typename std::add_lvalue_reference<T>::type;
1275#endif
1276
1277 //***************************************************************************
1279#if ETL_USING_CPP11
1280 template <typename T> struct add_rvalue_reference : std::add_rvalue_reference<T> {};
1281#endif
1282
1283#if ETL_USING_CPP11
1284 template <typename T>
1285 using add_rvalue_reference_t = typename std::add_rvalue_reference<T>::type;
1286#endif
1287
1288 //***************************************************************************
1290#if ETL_USING_CPP11
1291 template <typename T>
1292 typename std::add_rvalue_reference<T>::type declval() ETL_NOEXCEPT;
1293#endif
1294
1295#if ETL_USING_CPP11
1296 //***************************************************************************
1299 template <typename T>
1300 struct is_enum : std::is_enum<T>
1301 {
1302 };
1303
1304#if ETL_USING_CPP17
1305 template <typename T>
1306 inline constexpr bool is_enum_v = etl::is_enum<T>::value;
1307#endif
1308
1309#endif
1310
1311 //***************************************************************************
1314#if ETL_USING_CPP11
1315 template <typename TFrom, typename TTo>
1316 struct is_convertible : std::is_convertible<TFrom, TTo> {};
1317#endif
1318
1319#if ETL_USING_CPP17
1320 template <typename TFrom, typename TTo>
1321 inline constexpr bool is_convertible_v = std::is_convertible_v<TFrom, TTo>;
1322#endif
1323
1324 //***************************************************************************
1327 template <typename T> struct alignment_of : std::alignment_of<T> {};
1328 template <> struct alignment_of<void> : std::integral_constant<size_t, 0> {};
1329 template <> struct alignment_of<const void> : std::integral_constant <size_t, 0> {};
1330
1331#if ETL_USING_CPP17
1332 template <typename T>
1333 inline constexpr size_t alignment_of_v = std::alignment_of_v<T>;
1334#endif
1335
1336#endif // Condition = ETL_USING_STL && ETL_USING_CPP11
1337
1338 //***************************************************************************
1339 // ETL extended type traits.
1340 //***************************************************************************
1341
1342 //***************************************************************************
1344 // /\ingroup type_traits
1345 template <bool B, typename T, T TRUE_VALUE, T FALSE_VALUE>
1347
1348 template <typename T, T TRUE_VALUE, T FALSE_VALUE>
1350 {
1351 ETL_STATIC_ASSERT(etl::is_integral<T>::value, "Not an integral type");
1352 static const T value = TRUE_VALUE;
1353 };
1354
1355 template <typename T, T TRUE_VALUE, T FALSE_VALUE>
1357 {
1358 ETL_STATIC_ASSERT(etl::is_integral<T>::value, "Not an integral type");
1359 static const T value = FALSE_VALUE;
1360 };
1361
1362#if ETL_USING_CPP11
1363 //***************************************************************************
1366 template <typename T, typename T1, typename... TRest>
1367 struct is_one_of
1368 {
1369 static const bool value = etl::is_same<T, T1>::value ||
1370 etl::is_one_of<T, TRest...>::value;
1371 };
1372
1373 template <typename T, typename T1>
1374 struct is_one_of<T, T1>
1375 {
1376 static const bool value = etl::is_same<T, T1>::value;
1377 };
1378#else
1379 /*[[[cog
1380 import cog
1381 cog.outl("//***************************************************************************")
1382 cog.outl("/// Template to determine if a type is one of a specified list.")
1383 cog.outl("///\\ingroup types")
1384 cog.outl("template <typename T,")
1385 cog.out(" ")
1386 cog.out("typename T1, ")
1387 for n in range(2, int(IsOneOf)):
1388 cog.out("typename T%s = void, " % n)
1389 if n % 4 == 0:
1390 cog.outl("")
1391 cog.out(" ")
1392 cog.outl("typename T%s = void>" % IsOneOf)
1393 cog.outl("struct is_one_of")
1394 cog.outl("{")
1395 cog.outl(" static const bool value = ")
1396 for n in range(1, int(IsOneOf)):
1397 cog.outl(" etl::is_same<T, T%s>::value ||" % n)
1398 cog.outl(" etl::is_same<T, T%s>::value;" % IsOneOf)
1399 cog.outl("};")
1400 ]]]*/
1401 /*[[[end]]]*/
1402#endif
1403
1404#if ETL_USING_CPP17
1405 template <typename T, typename... TRest>
1406 inline constexpr bool is_one_of_v = etl::is_one_of<T, TRest...>::value;
1407#endif
1408
1409#if ETL_USING_CPP11
1410 //***************************************************************************
1413 template <typename T, typename T1, typename... TRest>
1414 struct is_base_of_all
1415 {
1416 static const bool value = etl::is_base_of<T, T1>::value &&
1417 etl::is_base_of_all<T, TRest...>::value;
1418 };
1419
1420 template <typename T, typename T1>
1421 struct is_base_of_all<T, T1>
1422 {
1423 static const bool value = etl::is_base_of<T, T1>::value;
1424 };
1425#endif
1426
1427#if ETL_USING_CPP17
1428 template <typename T, typename... TRest>
1429 inline constexpr bool is_base_of_all_v = etl::is_base_of_all<T, TRest...>::value;
1430#endif
1431
1432#if ETL_USING_CPP11
1433 //***************************************************************************
1436 template <typename T, typename T1, typename... TRest>
1437 struct is_base_of_any
1438 {
1439 static const bool value = etl::is_base_of<T, T1>::value ||
1440 etl::is_base_of_any<T, TRest...>::value;
1441 };
1442
1443 template <typename T, typename T1>
1444 struct is_base_of_any<T, T1>
1445 {
1446 static const bool value = etl::is_base_of<T, T1>::value;
1447 };
1448#endif
1449
1450#if ETL_USING_CPP17
1451 template <typename T, typename... TRest>
1452 inline constexpr bool is_base_of_any_v = etl::is_base_of_any<T, TRest...>::value;
1453#endif
1454
1455 //***************************************************************************
1458
1459 // Default.
1460 template <typename T>
1461 struct types
1462 {
1463 private:
1464
1466
1467 public:
1468
1469 typedef type_t type;
1470 typedef type_t& reference;
1471 typedef const type_t& const_reference;
1472 typedef type_t* pointer;
1473 typedef const type_t* const_pointer;
1474 typedef const type_t* const const_pointer_const;
1475
1476#if ETL_USING_CPP11
1477 typedef type_t&& rvalue_reference;
1478#endif
1479 };
1480
1481 // Pointers.
1482 template <typename T>
1483 struct types<T*>
1484 {
1485 private:
1486
1488
1489 public:
1490
1491 typedef type_t type;
1492 typedef type_t& reference;
1493 typedef const type_t& const_reference;
1494 typedef type_t* pointer;
1495 typedef const type_t* const_pointer;
1496 typedef const type_t* const const_pointer_const;
1497
1498#if ETL_USING_CPP11
1499 typedef type_t&& rvalue_reference;
1500#endif
1501 };
1502
1503 // Pointers.
1504 template <typename T>
1505 struct types<T* const>
1506 {
1507 private:
1508
1510
1511 public:
1512
1513 typedef type_t type;
1514 typedef type_t& reference;
1515 typedef const type_t& const_reference;
1516 typedef type_t* pointer;
1517 typedef const type_t* const_pointer;
1518 typedef const type_t* const const_pointer_const;
1519
1520#if ETL_USING_CPP11
1521 typedef type_t&& rvalue_reference;
1522#endif
1523 };
1524
1525 // References.
1526 template <typename T>
1527 struct types<T&>
1528 {
1529 private:
1530
1532
1533 public:
1534
1535 typedef type_t type;
1536 typedef type_t& reference;
1537 typedef const type_t& const_reference;
1538 typedef type_t* pointer;
1539 typedef const type_t* const_pointer;
1540 typedef const type_t* const const_pointer_const;
1541
1542#if ETL_USING_CPP11
1543 typedef type_t&& rvalue_reference;
1544#endif
1545 };
1546
1547#if ETL_USING_CPP11
1548 // rvalue References.
1549 template <typename T>
1550 struct types<T&&>
1551 {
1552 private:
1553
1554 typedef typename etl::remove_reference<typename etl::remove_cv<T>::type>::type type_t;
1555
1556 public:
1557
1558 typedef type_t type;
1559 typedef type_t& reference;
1560 typedef const type_t& const_reference;
1561 typedef type_t* pointer;
1562 typedef const type_t* const_pointer;
1563 typedef const type_t* const const_pointer_const;
1564
1565#if ETL_USING_CPP11
1566 typedef type_t&& rvalue_reference;
1567#endif
1568 };
1569#endif
1570
1571#if ETL_USING_CPP11
1572 template <typename T>
1573 using types_t = typename types<T>::type;
1574
1575 template <typename T>
1576 using types_r = typename types<T>::reference;
1577
1578 template <typename T>
1579 using types_cr = typename types<T>::const_reference;
1580
1581 template <typename T>
1582 using types_rr = typename types<T>::rvalue_reference;
1583
1584 template <typename T>
1585 using types_p = typename types<T>::pointer;
1586
1587 template <typename T>
1588 using types_cp = typename types<T>::const_pointer;
1589
1590 template <typename T>
1591 using types_cpc = typename types<T>::const_pointer_const;
1592#endif
1593
1594 //***************************************************************************
1597 template <typename T> struct size_of : etl::integral_constant<size_t, sizeof(T)> {};
1598 template <> struct size_of<void> : etl::integral_constant<size_t, 1U> {};
1599
1600#if ETL_USING_CPP17
1601 template <typename T>
1602 inline constexpr size_t size_of_v = etl::size_of<T>::value;
1603#endif
1604
1605#if ETL_USING_CPP11
1606 //***************************************************************************
1608 template <typename T, typename T1, typename... TRest>
1609 struct are_all_same
1610 {
1611 static const bool value = etl::is_same<T, T1>::value &&
1612 etl::are_all_same<T, TRest...>::value;
1613 };
1614
1615 template <typename T, typename T1>
1616 struct are_all_same<T, T1>
1617 {
1618 static const bool value = etl::is_same<T, T1>::value;
1619 };
1620#endif
1621
1622#if ETL_USING_CPP17
1623 template <typename T, typename T1, typename... TRest>
1624 inline constexpr bool are_all_same_v = are_all_same<T, T1, TRest...>::value;
1625#endif
1626
1627 //***************************************************************************
1629#if ETL_USING_CPP11
1630 template <typename...>
1631 struct conjunction : public etl::true_type
1632 {
1633 };
1634
1635 template <typename T1, typename... Tn>
1636 struct conjunction<T1, Tn...> : public etl::conditional_t<bool(T1::value), etl::conjunction<Tn...>, T1>
1637 {
1638 };
1639
1640 template <typename T>
1641 struct conjunction<T> : public T
1642 {
1643 };
1644#endif
1645
1646#if ETL_USING_CPP17
1647 template <typename... T>
1648 inline constexpr bool conjunction_v = conjunction<T...>::value;
1649#endif
1650
1651 //***************************************************************************
1653#if ETL_USING_CPP11
1654 template <typename...>
1655 struct disjunction : public etl::false_type
1656 {
1657 };
1658
1659 template <typename T1, typename... Tn>
1660 struct disjunction<T1, Tn...> : public etl::conditional_t<bool(T1::value), T1, disjunction<Tn...>>
1661 {
1662 };
1663
1664 template <typename T1> struct disjunction<T1> : public T1
1665 {
1666 };
1667#endif
1668
1669#if ETL_USING_CPP17
1670 template <typename... T>
1671 inline constexpr bool disjunction_v = etl::disjunction<T...>::value;
1672#endif
1673
1674 //***************************************************************************
1675#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))
1676
1677 //*********************************************
1678 // Use the STL's definitions.
1679 //*********************************************
1680
1681 //*********************************************
1682 // is_assignable
1683 template<typename T1, typename T2>
1684 using is_assignable = std::is_assignable<T1, T2>;
1685
1686 //*********************************************
1687 // is_constructible
1688 template<typename T, typename... TArgs>
1689 using is_constructible = std::is_constructible<T, TArgs...>;
1690
1691 //*********************************************
1692 // is_copy_constructible
1693 template <typename T>
1694 using is_copy_constructible = std::is_copy_constructible<T>;
1695
1696 //*********************************************
1697 // is_move_constructible
1698 template <typename T>
1699 using is_move_constructible = std::is_move_constructible<T>;
1700
1701 //*********************************************
1702 // is_trivially_constructible
1703#if ETL_CPP11_TYPE_TRAITS_IS_TRIVIAL_SUPPORTED
1704 template <typename T>
1705 using is_trivially_constructible = std::is_trivially_constructible<T>;
1706#else
1707 template <typename T>
1709#endif
1710
1711 //*********************************************
1712 // is_trivially_copy_constructible
1713#if ETL_CPP11_TYPE_TRAITS_IS_TRIVIAL_SUPPORTED
1714 template <typename T>
1715 using is_trivially_copy_constructible = std::is_trivially_copy_constructible<T>;
1716#else
1717 template <typename T>
1718 using is_trivially_copy_constructible = etl::bool_constant<etl::is_arithmetic<T>::value || etl::is_pointer<T>::value>;
1719#endif
1720
1721 //*********************************************
1722 // is_trivially_destructible
1723#if ETL_CPP11_TYPE_TRAITS_IS_TRIVIAL_SUPPORTED
1724 template <typename T>
1725 using is_trivially_destructible = std::is_trivially_destructible<T>;
1726#else
1727 template <typename T>
1729#endif
1730
1731 //*********************************************
1732 // is_trivially_copy_assignable
1733#if ETL_CPP11_TYPE_TRAITS_IS_TRIVIAL_SUPPORTED
1734 template <typename T>
1735 using is_trivially_copy_assignable = std::is_trivially_copy_assignable<T>;
1736#else
1737 template <typename T>
1738 using is_trivially_copy_assignable = etl::bool_constant<etl::is_arithmetic<T>::value || etl::is_pointer<T>::value>;
1739#endif
1740
1741 //*********************************************
1742 // is_trivially_copyable
1743#if ETL_CPP11_TYPE_TRAITS_IS_TRIVIAL_SUPPORTED
1744 template <typename T>
1745 using is_trivially_copyable = std::is_trivially_copyable<T>;
1746#else
1747 template <typename T>
1749#endif
1750
1751#elif defined(ETL_USE_TYPE_TRAITS_BUILTINS) && !defined(ETL_USER_DEFINED_TYPE_TRAITS)
1752
1753 //*********************************************
1754 // Use the compiler's builtins.
1755 //*********************************************
1756
1757 //*********************************************
1758 // is_assignable
1759 template<typename T1, typename T2>
1760 struct is_assignable
1761 {
1762 static ETL_CONSTANT bool value = __is_assignable(T1, T2);
1763 };
1764
1765#if ETL_USING_CPP11
1766 //*********************************************
1767 // is_constructible
1768 template<typename T, typename... TArgs>
1769 struct is_constructible
1770 {
1771 static ETL_CONSTANT bool value = __is_constructible(T, TArgs...);
1772 };
1773#else
1774 //*********************************************
1775 // is_constructible
1776 template<typename T, typename TArgs = void>
1777 struct is_constructible
1778 {
1779 static ETL_CONSTANT bool value = __is_constructible(T, TArgs);
1780 };
1781
1782 //*********************************************
1783 // is_constructible
1784 template<typename T>
1785 struct is_constructible<T, void>
1786 {
1787 static ETL_CONSTANT bool value = __is_constructible(T);
1788 };
1789#endif
1790
1791 //*********************************************
1792 // is_copy_constructible
1793 template <typename T>
1794 struct is_copy_constructible : public etl::is_constructible<T, typename etl::add_lvalue_reference<const T>::type>
1795 {
1796 };
1797
1798 //*********************************************
1799 // is_move_constructible
1800 template <typename T>
1801 struct is_move_constructible : public etl::is_constructible<T, T>
1802 {
1803 };
1804
1805#if ETL_USING_CPP11
1806 //*********************************************
1807 // is_trivially_constructible
1808 template <typename T, typename... TArgs>
1809 struct is_trivially_constructible
1810 {
1811#if defined(ETL_COMPILER_GCC)
1812 static ETL_CONSTANT bool value = __has_trivial_constructor(T);
1813#else
1814 static ETL_CONSTANT bool value = __is_trivially_constructible(T, TArgs...);
1815#endif
1816 };
1817#else
1818 //*********************************************
1819 // is_trivially_constructible
1820 template <typename T, typename TArgs = void>
1821 struct is_trivially_constructible
1822 {
1823#if defined(ETL_COMPILER_GCC)
1824 static ETL_CONSTANT bool value = __has_trivial_constructor(T);
1825#else
1826 static ETL_CONSTANT bool value = __is_trivially_constructible(T, TArgs);
1827#endif
1828 };
1829
1830 //*********************************************
1831 // is_trivially_constructible
1832 template <typename T>
1833 struct is_trivially_constructible<T, void>
1834 {
1835#if defined(ETL_COMPILER_GCC)
1836 static ETL_CONSTANT bool value = __has_trivial_constructor(T);
1837#else
1838 static ETL_CONSTANT bool value = __is_trivially_constructible(T);
1839#endif
1840 };
1841#endif
1842
1843 //*********************************************
1844 // is_trivially_copy_constructible
1845 template <typename T>
1846 struct is_trivially_copy_constructible : public is_trivially_constructible<T, typename add_lvalue_reference<const T>::type>
1847 {
1848 };
1849
1850 //*********************************************
1851 // is_trivially_destructible
1852 template <typename T>
1853 struct is_trivially_destructible
1854 {
1855#if defined(ETL_COMPILER_GCC)
1856 static ETL_CONSTANT bool value = __has_trivial_destructor(T);
1857#else
1858 static ETL_CONSTANT bool value = __is_trivially_destructible(T);
1859#endif
1860 };
1861
1862 //*********************************************
1863 // is_trivially_copy_assignable
1864 template <typename T>
1865 struct is_trivially_copy_assignable
1866 {
1867#if defined(ETL_COMPILER_GCC)
1868 static ETL_CONSTANT bool value = __has_trivial_copy(T);
1869#else
1870 static ETL_CONSTANT bool value = __is_trivially_copyable(T);
1871#endif
1872 };
1873
1874 //*********************************************
1875 // is_trivially_copyable
1876 template <typename T>
1877 struct is_trivially_copyable
1878 {
1879#if defined(ETL_COMPILER_GCC)
1880 static ETL_CONSTANT bool value = __has_trivial_copy(T);
1881#else
1882 static ETL_CONSTANT bool value = __is_trivially_copyable(T);
1883#endif
1884 };
1885
1886#elif defined(ETL_USER_DEFINED_TYPE_TRAITS) && !defined(ETL_USE_TYPE_TRAITS_BUILTINS)
1887
1888 //*********************************************
1889 // Force the user to provide specialisations for
1890 // anything other than arithmetics and pointers.
1891 //*********************************************
1892
1893 //*********************************************
1894 // is_assignable
1895 template <typename T1,
1896 typename T2,
1898 struct is_assignable;
1899
1900 template <typename T1, typename T2>
1901 struct is_assignable<T1, T2, true> : public etl::true_type
1902 {
1903 };
1904
1905 template <typename T1, typename T2>
1906 struct is_assignable<T1, T2, false>;
1907
1908#if ETL_USING_CPP11
1909 //*********************************************
1910 // is_constructible
1911 template <typename T, bool B, typename... TArgs>
1912 struct is_constructible_helper;
1913
1914 template <typename T, typename... TArgs>
1915 struct is_constructible_helper<T, true, TArgs...> : public etl::true_type
1916 {
1917 };
1918
1919 template <typename T, typename... TArgs>
1920 struct is_constructible_helper<T, false, TArgs...>;
1921
1922 template <typename T, typename... TArgs>
1923 struct is_constructible : public is_constructible_helper<T, etl::is_arithmetic<T>::value || etl::is_pointer<T>::value, TArgs...>
1924 {
1925 };
1926#endif
1927
1928 //*********************************************
1929 // is_copy_constructible
1930 template <typename T, bool B = etl::is_arithmetic<T>::value || etl::is_pointer<T>::value>
1931 struct is_copy_constructible;
1932
1933 template <typename T>
1934 struct is_copy_constructible<T, true> : public etl::true_type
1935 {
1936 };
1937
1938 template <typename T>
1939 struct is_copy_constructible<T, false>;
1940
1941 //*********************************************
1942 // is_move_constructible
1943 template <typename T, bool B = etl::is_arithmetic<T>::value || etl::is_pointer<T>::value>
1944 struct is_move_constructible;
1945
1946 template <typename T>
1947 struct is_move_constructible<T, true> : public etl::true_type
1948 {
1949 };
1950
1951 template <typename T>
1952 struct is_move_constructible<T, false>;
1953
1954 //*********************************************
1955 // is_trivially_constructible
1956 template <typename T, bool B = etl::is_arithmetic<T>::value || etl::is_pointer<T>::value>
1957 struct is_trivially_constructible;
1958
1959 template <typename T>
1960 struct is_trivially_constructible<T, true> : public etl::true_type
1961 {
1962 };
1963
1964 template <typename T>
1965 struct is_trivially_constructible<T, false>;
1966
1967 //*********************************************
1968 // is_trivially_copy_constructible
1969 template <typename T, bool B = etl::is_arithmetic<T>::value || etl::is_pointer<T>::value>
1970 struct is_trivially_copy_constructible;
1971
1972 template <typename T>
1973 struct is_trivially_copy_constructible<T, true> : public etl::true_type
1974 {
1975 };
1976
1977 template <typename T>
1978 struct is_trivially_copy_constructible<T, false>;
1979
1980 //*********************************************
1981 // is_trivially_destructible
1982 template <typename T, bool B = etl::is_arithmetic<T>::value || etl::is_pointer<T>::value>
1983 struct is_trivially_destructible;
1984
1985 template <typename T>
1986 struct is_trivially_destructible<T, true> : public etl::true_type
1987 {
1988 };
1989
1990 template <typename T>
1991 struct is_trivially_destructible<T, false>;
1992
1993 //*********************************************
1994 // is_trivially_copy_assignable
1995 template <typename T, bool B = etl::is_arithmetic<T>::value || etl::is_pointer<T>::value>
1996 struct is_trivially_copy_assignable;
1997
1998 template <typename T>
1999 struct is_trivially_copy_assignable<T, true> : public etl::true_type
2000 {
2001 };
2002
2003 template <typename T>
2004 struct is_trivially_copy_assignable<T, false>;
2005
2006 //*********************************************
2007 // is_trivially_copyable
2008 template <typename T, bool B = etl::is_arithmetic<T>::value || etl::is_pointer<T>::value>
2009 struct is_trivially_copyable;
2010
2011 template <typename T>
2012 struct is_trivially_copyable<T, true> : public etl::true_type
2013 {
2014 };
2015
2016 template <typename T>
2017 struct is_trivially_copyable<T, false>;
2018
2019#else
2020
2021 //*********************************************
2022 // Assume that anything other than arithmetics
2023 // and pointers return false for the traits.
2024 //*********************************************
2025
2026 //*********************************************
2027 // is_assignable
2028 template <typename T1, typename T2>
2029 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)>
2030 {
2031 };
2032
2033#if ETL_USING_CPP11
2034 //***************************************************************************
2036 namespace private_type_traits
2037 {
2038 template <class, class T, class... Args>
2040
2041 template <class T, class... Args>
2042 struct is_constructible_<void_t<decltype(T(etl::declval<Args>()...))>, T, Args...> : etl::true_type {};
2043 }
2044
2045 //*********************************************
2046 // is_constructible
2047 template <class T, class... Args>
2048 using is_constructible = private_type_traits::is_constructible_<void_t<>, T, Args...>;
2049
2050 //*********************************************
2051 // is_copy_constructible
2052 template <class T> struct is_copy_constructible : public is_constructible<T, typename etl::add_lvalue_reference<typename etl::add_const<T>::type>::type>{};
2053 template <> struct is_copy_constructible<void> : public false_type{};
2054 template <> struct is_copy_constructible<void const> : public false_type{};
2055 template <> struct is_copy_constructible<void volatile> : public false_type{};
2056 template <> struct is_copy_constructible<void const volatile> : public false_type{};
2057
2058 //*********************************************
2059 // is_move_constructible
2060 template <typename T> struct is_move_constructible: public is_constructible<T, typename etl::add_rvalue_reference<T>::type>{};
2061 template <> struct is_move_constructible<void> : public false_type{};
2062 template <> struct is_move_constructible<void const> : public false_type{};
2063 template <> struct is_move_constructible<void volatile> : public false_type{};
2064 template <> struct is_move_constructible<void const volatile> : public false_type{};
2065
2066#else
2067
2068 //*********************************************
2069 // is_copy_constructible
2070 template <typename T>
2071 struct is_copy_constructible : public etl::bool_constant<etl::is_arithmetic<T>::value || etl::is_pointer<T>::value>
2072 {
2073 };
2074
2075 //*********************************************
2076 // is_move_constructible
2077 template <typename T>
2078 struct is_move_constructible : public etl::bool_constant<etl::is_arithmetic<T>::value || etl::is_pointer<T>::value>
2079 {
2080 };
2081#endif
2082
2083 //*********************************************
2084 // is_trivially_constructible
2085 template <typename T>
2086 struct is_trivially_constructible : public etl::bool_constant<etl::is_arithmetic<T>::value || etl::is_pointer<T>::value>
2087 {
2088 };
2089
2090 //*********************************************
2091 // is_trivially_copy_constructible
2092 template <typename T>
2093 struct is_trivially_copy_constructible : public etl::bool_constant<etl::is_arithmetic<T>::value || etl::is_pointer<T>::value>
2094 {
2095 };
2096
2097 //*********************************************
2098 // is_trivially_destructible
2099 template <typename T>
2100 struct is_trivially_destructible : public etl::bool_constant<etl::is_arithmetic<T>::value || etl::is_pointer<T>::value>
2101 {
2102 };
2103
2104 //*********************************************
2105 // is_trivially_copy_assignable
2106 template <typename T>
2107 struct is_trivially_copy_assignable : public etl::bool_constant<etl::is_arithmetic<T>::value || etl::is_pointer<T>::value>
2108 {
2109 };
2110
2111 //*********************************************
2112 // is_trivially_copyable
2113 template <typename T>
2114 struct is_trivially_copyable : public etl::bool_constant<etl::is_arithmetic<T>::value || etl::is_pointer<T>::value>
2115 {
2116 };
2117
2118#endif
2119
2120 template <typename T1, typename T2>
2121 struct is_lvalue_assignable : public etl::is_assignable<typename etl::add_lvalue_reference<T1>::type,
2122 typename etl::add_lvalue_reference<typename etl::add_const<T2>::type>::type>
2123 {
2124 };
2125
2126#if ETL_USING_CPP11
2127 //*********************************************
2128 // is_default_constructible
2129 template<typename T, typename = void>
2131
2132 template<typename T>
2133 struct is_default_constructible<T, etl::void_t<decltype(T())>> : etl::true_type { };
2134#else
2135 template <typename T>
2136 struct is_default_constructible : public etl::bool_constant<etl::is_arithmetic<T>::value || etl::is_pointer<T>::value>
2137 {
2138 };
2139#endif
2140
2141#if ETL_USING_CPP17
2142
2143 template <typename T1, typename T2>
2144 inline constexpr bool is_assignable_v = etl::is_assignable<T1, T2>::value;
2145
2146 template <typename T1, typename T2>
2148
2149 template<typename T, typename... TArgs>
2150 inline constexpr bool is_constructible_v = etl::is_constructible<T, TArgs...>::value;
2151
2152 template<typename T, typename... TArgs>
2153 inline constexpr bool is_default_constructible_v = etl::is_default_constructible<T, TArgs...>::value;
2154
2155 template<typename T>
2157
2158 template<typename T>
2160
2161 template <typename T>
2163
2164 template <typename T>
2166
2167 template <typename T>
2169
2170 template <typename T>
2172
2173 template <typename T>
2175
2176#endif
2177
2178#if ETL_USING_CPP11
2179 //*********************************************
2180 // common_type
2181 // Based on the sample implementation detailed on
2182 // https://en.cppreference.com/w/cpp/types/common_type
2183 //*********************************************
2184 //***********************************
2185 // Primary template
2186 template<typename...>
2187 struct common_type
2188 {
2189 };
2190
2191 //***********************************
2192 // One type
2193 template <typename T>
2194 struct common_type<T> : common_type<T, T>
2195 {
2196 };
2197
2198 namespace private_common_type
2199 {
2200 template <typename T1, typename T2>
2201 using conditional_result_t = decltype(false ? declval<T1>() : declval<T2>());
2202
2203 template <typename, typename, typename = void>
2204 struct decay_conditional_result
2205 {
2206 };
2207
2208 template <typename T1, typename T2>
2209 struct decay_conditional_result<T1, T2, void_t<conditional_result_t<T1, T2>>>
2211 {
2212 };
2213
2214 template <typename T1, typename T2, typename = void>
2215 struct common_type_2_impl : decay_conditional_result<const T1&, const T2&>
2216 {
2217 };
2218
2219 template <typename T1, typename T2>
2220 struct common_type_2_impl<T1, T2, void_t<conditional_result_t<T1, T2>>>
2221 : decay_conditional_result<T1, T2>
2222 {
2223 };
2224 }
2225
2226 //***********************************
2227 // Two types
2228 template <typename T1, typename T2>
2229 struct common_type<T1, T2>
2230 : etl::conditional<etl::is_same<T1, typename etl::decay<T1>::type>::value&& etl::is_same<T2, typename etl::decay<T2>::type>::value,
2231 private_common_type::common_type_2_impl<T1, T2>,
2232 common_type<typename etl::decay<T2>::type,
2233 typename etl::decay<T2>::type>>::type
2234 {
2235 };
2236
2237 //***********************************
2238 // Three or more types
2239 namespace private_common_type
2240 {
2241 template <typename AlwaysVoid, typename T1, typename T2, typename... TRest>
2243 {
2244 };
2245
2246 template <typename T1, typename T2, typename... TRest>
2248 : common_type<typename common_type<T1, T2>::type, TRest...>
2249 {
2250 };
2251 }
2252
2253 template<typename T1, typename T2, typename... TRest>
2254 struct common_type<T1, T2, TRest...>
2255 : private_common_type::common_type_multi_impl<void, T1, T2, TRest...>
2256 {
2257 };
2258
2259 template <typename... T>
2260 using common_type_t = typename common_type<T...>::type;
2261#endif
2262
2263 //***************************************************************************
2265 //***************************************************************************
2266 template <typename T>
2268 {
2269 typedef typename etl::conditional<sizeof(T) == sizeof(unsigned char), unsigned char,
2270 typename etl::conditional<sizeof(T) == sizeof(unsigned short), unsigned short,
2271 typename etl::conditional<sizeof(T) == sizeof(unsigned int), unsigned int,
2272 typename etl::conditional<sizeof(T) == sizeof(unsigned long), unsigned long,
2273 unsigned long long>::type>::type>::type>::type type;
2274 };
2275
2276#if ETL_USING_CPP11
2277 template <typename T>
2278 using unsigned_type_t = typename unsigned_type<T>::type;
2279#endif
2280
2281 //***************************************************************************
2283 //***************************************************************************
2284 template <typename T>
2286 {
2287 typedef typename etl::conditional<sizeof(T) == sizeof(char), char,
2288 typename etl::conditional<sizeof(T) == sizeof(short), short,
2289 typename etl::conditional<sizeof(T) == sizeof(int), int,
2290 typename etl::conditional<sizeof(T) == sizeof(long), long,
2291 long long>::type>::type>::type>::type type;
2292 };
2293
2294#if ETL_USING_CPP11
2295 template <typename T>
2296 using signed_type_t = typename signed_type<T>::type;
2297#endif
2298
2299 //*********************************************
2300 // type_identity
2301
2302 template <typename T>
2303 struct type_identity { typedef T type; };
2304
2305#if ETL_USING_CPP11
2306 template <typename T>
2307 using type_identity_t = typename type_identity<T>::type;
2308#endif
2309
2310#if ETL_USING_CPP11
2311 //*********************************************
2312 // has_duplicates
2313 template <typename... TTypes>
2314 struct has_duplicates;
2315
2316 template <typename TFirst, typename... TRest>
2317 struct has_duplicates<TFirst, TRest...> : etl::conditional_t<etl::is_one_of<TFirst, TRest...>::value,
2318 etl::true_type,
2319 has_duplicates<TRest...>> {};
2320 template <typename TFirst>
2321 struct has_duplicates<TFirst> : etl::false_type {};
2322 template <>
2323 struct has_duplicates<> : etl::false_type {};
2324#endif
2325
2326#if ETL_USING_CPP17
2327 template <typename... TTypes>
2328 inline constexpr bool has_duplicates_v = etl::has_duplicates<TTypes...>::value;
2329#endif
2330
2331#if ETL_USING_CPP11
2332 //*********************************************
2333 // count_of
2334 template <typename T, typename... TTypes>
2335 struct count_of;
2336
2337 template <typename T, typename U, typename... URest>
2338 struct count_of<T, U, URest...> : etl::integral_constant<size_t,
2339 etl::is_same<T, U>::value +
2340 count_of<T, URest...>::value> {};
2341
2342 template <typename T>
2343 struct count_of<T> : etl::integral_constant<size_t, 0> {};
2344#endif
2345
2346#if ETL_USING_CPP17
2347 template <typename T, typename... TTypes>
2348 inline constexpr size_t count_of_v = etl::count_of<T, TTypes...>::value;
2349#endif
2350
2351#if ETL_USING_CPP11
2352 //*********************************************
2353 // has_duplicates_of
2354 template <typename T, typename... TTypes>
2355 struct has_duplicates_of : etl::bool_constant<(etl::count_of<T, TTypes...>::value > 1U)> {};
2356#endif
2357
2358#if ETL_USING_CPP17
2359 template <typename T, typename... TTypes>
2360 inline constexpr bool has_duplicates_of_v = etl::has_duplicates_of<T, TTypes...>::value;
2361#endif
2362}
2363
2364// Helper macros
2365#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)
2366#define ETL_IS_NOT_CHAR_TYPE(type) (!ETL_IS_CHAR_TYPE(type))
2367
2368#define ETL_IS_POINTER_TYPE(type) (etl::is_pointer<type>::value)
2369#define ETL_IS_NOT_POINTER_TYPE(type) (!ETL_IS_POINTER_TYPE(type))
2370
2371#define ETL_TARGET_IS_TRIVIALLY_COPYABLE(type) (etl::is_trivially_copyable<typename etl::iterator_traits<type>::value_type>::value)
2372#define ETL_TARGET_IS_NOT_TRIVIALLY_COPYABLE(type) (!ETL_TARGET_IS_TRIVIALLY_COPYABLE(type))
2373
2374#endif // ETL_TYPE_TRAITS_INCLUDED
integral_constant< bool, false > false_type
integral_constant specialisations
Definition type_traits_generator.h:836
add_const
Definition type_traits_generator.h:928
add_cv
Definition type_traits_generator.h:978
add_pointer
Definition type_traits_generator.h:898
add_volatile
Definition type_traits_generator.h:958
add_rvalue_reference
Definition type_traits_generator.h:1327
conditional
Definition type_traits_generator.h:1160
decay
Definition type_traits_generator.h:1242
enable_if
Definition type_traits_generator.h:1191
extent
Definition type_traits_generator.h:1202
integral_constant
Definition type_traits_generator.h:832
is_arithmetic
Definition type_traits_generator.h:1061
is_array
Definition type_traits_generator.h:1091
is_base_of
Definition type_traits_generator.h:1252
is_compound
Definition type_traits_generator.h:1081
is_const
Definition type_traits_generator.h:908
is_floating_point
Definition type_traits_generator.h:1031
is_fundamental
Definition type_traits_generator.h:1071
is_integral
Definition type_traits_generator.h:1001
is_lvalue_reference
Definition type_traits_generator.h:1121
is_rvalue_reference
Definition type_traits_generator.h:1144
is_pointer
Definition type_traits_generator.h:1101
is_reference
Definition type_traits_generator.h:1111
is_same
Definition type_traits_generator.h:1041
is_signed
Definition type_traits_generator.h:1011
is_unsigned
Definition type_traits_generator.h:1021
is_void
Definition type_traits_generator.h:1051
is_volatile
Definition type_traits_generator.h:938
make_signed
Definition type_traits_generator.h:1171
make_unsigned
Definition type_traits_generator.h:1181
negation
Definition type_traits_generator.h:866
rank
Definition type_traits_generator.h:1232
remove_all_extents
Definition type_traits_generator.h:1222
remove_const
Definition type_traits_generator.h:918
remove_cv
Definition type_traits_generator.h:968
remove_cvref
Definition type_traits_generator.h:989
remove_extent
Definition type_traits_generator.h:1212
remove_pointer
Definition type_traits_generator.h:888
remove_reference
Definition type_traits_generator.h:878
remove_volatile
Definition type_traits_generator.h:948
bitset_ext
Definition absolute.h:38
add_lvalue_reference
Definition type_traits_generator.h:1270
Definition type_traits_generator.h:849
conditional_integral_constant
Definition type_traits_generator.h:1346
conjunction
Definition type_traits_generator.h:2030
is_class
Definition type_traits_generator.h:1261
Definition type_traits_generator.h:2072
Definition type_traits_generator.h:2137
Definition type_traits_generator.h:2123
Definition type_traits_generator.h:2079
Definition type_traits_generator.h:2087
Definition type_traits_generator.h:2108
Definition type_traits_generator.h:2094
Definition type_traits_generator.h:2115
Definition type_traits_generator.h:2101
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:2286
size_of
Definition type_traits_generator.h:1597
Definition type_traits_generator.h:2303
A set of templates to allow related types to be derived.
Definition type_traits_generator.h:1462
Defines one of five unsigned types that has the same size as T.
Definition type_traits_generator.h:2268
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