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