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