Embedded Template Library  1.0
type_traits.h
Go to the documentation of this file.
1 
3 /******************************************************************************
4 The MIT License(MIT)
5 
6 Embedded Template Library.
7 https://github.com/ETLCPP/etl
8 https://www.etlcpp.com
9 
10 Copyright(c) 2014 jwellbelove
11 
12 Permission is hereby granted, free of charge, to any person obtaining a copy
13 of this software and associated documentation files(the "Software"), to deal
14 in the Software without restriction, including without limitation the rights
15 to use, copy, modify, merge, publish, distribute, sublicense, and / or sell
16 copies of the Software, and to permit persons to whom the Software is
17 furnished to do so, subject to the following conditions :
18 
19 The above copyright notice and this permission notice shall be included in all
20 copies or substantial portions of the Software.
21 
22 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
23 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
24 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE
25 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
26 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
27 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
28 SOFTWARE.
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 <stddef.h>
57 #include <stdint.h>
58 
59 #include "platform.h"
60 #include "nullptr.h"
61 #include "static_assert.h"
62 
67 
68 #if ETL_USING_STL && ETL_CPP11_SUPPORTED
69  #include <type_traits>
70 #endif
71 
72 namespace etl
73 {
74 #if ETL_NOT_USING_STL || ETL_CPP11_NOT_SUPPORTED
75 
76  //*****************************************************************************
77  // Traits are defined by the ETL
78  //*****************************************************************************
79  //***************************************************************************
81  template <typename T, const T VALUE>
82  struct integral_constant
83  {
84  static const T value = VALUE;
85 
86  typedef T value_type;
87  typedef integral_constant<T, VALUE> type;
88 
89  operator value_type() const
90  {
91  return value;
92  }
93  };
94 
96  typedef integral_constant<bool, false> false_type;
97  typedef integral_constant<bool, true> true_type;
98 
99  template <typename T, const T VALUE>
100  const T integral_constant<T, VALUE>::value;
101 
102 #if ETL_CPP11_SUPPORTED
103  template <bool B>
104  using bool_constant = integral_constant<bool, B>;
105 #else
106  template <bool B>
107  struct bool_constant : etl::integral_constant<bool, B> { };
108 #endif
109 
110  //***************************************************************************
112  template <typename T>
113  struct negation : etl::bool_constant<!bool(T::value)>
114  {
115  };
116 
117 #if ETL_CPP17_SUPPORTED
118  template <typename T>
119  inline constexpr bool negation_v = negation<T>::value;
120 #endif
121 
122  //***************************************************************************
124  template <typename T> struct remove_reference { typedef T type; };
125  template <typename T> struct remove_reference<T&> { typedef T type; };
126 
127 #if ETL_CPP14_SUPPORTED
128  template <typename T>
129  using remove_reference_t = typename remove_reference<T>::type;
130 #endif
131 
132  //***************************************************************************
134  template <typename T> struct remove_pointer { typedef T type; };
135  template <typename T> struct remove_pointer<T*> { typedef T type; };
136  template <typename T> struct remove_pointer<const T*> { typedef const T type; };
137  template <typename T> struct remove_pointer<volatile T*> { typedef volatile T type; };
138  template <typename T> struct remove_pointer<const volatile T*> { typedef const volatile T type; };
139  template <typename T> struct remove_pointer<T* const> { typedef T type; };
140  template <typename T> struct remove_pointer<const T* const> { typedef const T type; };
141  template <typename T> struct remove_pointer<volatile T* const> { typedef volatile T type; };
142  template <typename T> struct remove_pointer<const volatile T* const> { typedef const volatile T type; };
143 
144 #if ETL_CPP14_SUPPORTED
145  template <typename T>
146  using remove_pointer_t = typename remove_pointer<T>::type;
147 #endif
148 
149  //***************************************************************************
151  template <typename T> struct add_pointer { typedef typename remove_reference<T>::type* type; };
152 
153 #if ETL_CPP14_SUPPORTED
154  template <typename T>
155  using add_pointer_t = typename add_pointer<T>::type;
156 #endif
157 
158  //***************************************************************************
160  template <typename T> struct is_const : false_type {};
161  template <typename T> struct is_const<const T> : true_type {};
162  template <typename T> struct is_const<const volatile T> : true_type {};
163 
164 #if ETL_CPP17_SUPPORTED
165  template <typename T>
166  inline constexpr bool is_const_v = is_const<T>::value;
167 #endif
168 
169  //***************************************************************************
171  template <typename T> struct remove_const { typedef T type; };
172  template <typename T> struct remove_const<const T> { typedef T type; };
173 
174 #if ETL_CPP14_SUPPORTED
175  template <typename T>
176  using remove_const_t = typename remove_const<T>::type;
177 #endif
178 
179  //***************************************************************************
181  template <typename T> struct add_const { typedef const T type; };
182  template <typename T> struct add_const<const T> { typedef const T type; };
183 
184 #if ETL_CPP14_SUPPORTED
185  template <typename T>
186  using add_const_t = typename add_const<T>::type;
187 #endif
188 
189  //***************************************************************************
191  template <typename T> struct is_volatile : false_type {};
192  template <typename T> struct is_volatile<volatile T> : true_type {};
193  template <typename T> struct is_volatile<const volatile T> : true_type {};
194 
195 #if ETL_CPP17_SUPPORTED
196  template <typename T>
197  inline constexpr bool is_volatile_v = is_volatile<T>::value;
198 #endif
199 
200  //***************************************************************************
202  template <typename T> struct remove_volatile { typedef T type; };
203  template <typename T> struct remove_volatile<volatile T> { typedef T type; };
204 
205 #if ETL_CPP14_SUPPORTED
206  template <typename T>
207  using remove_volatile_t = typename remove_volatile<T>::type;
208 #endif
209 
210  //***************************************************************************
212  template <typename T> struct add_volatile { typedef volatile T type; };
213  template <typename T> struct add_volatile<volatile T> { typedef volatile T type; };
214 
215 #if ETL_CPP14_SUPPORTED
216  template <typename T>
217  using add_volatile_t = typename add_volatile<T>::type;
218 #endif
219 
220  //***************************************************************************
222  template <typename T> struct remove_cv
223  {
224  typedef typename remove_volatile<typename remove_const<T>::type>::type type;
225  };
226 
227 #if ETL_CPP14_SUPPORTED
228  template <typename T>
229  using remove_cv_t = typename remove_cv<T>::type;
230 #endif
231 
232  //***************************************************************************
234  template <typename T> struct add_cv
235  {
236  typedef typename add_volatile<typename add_const<T>::type>::type type;
237  };
238 
239 #if ETL_CPP14_SUPPORTED
240  template <typename T>
241  using add_cv_t = typename add_cv<T>::type;
242 #endif
243 
244  //***************************************************************************
246  template <typename T> struct is_integral : false_type {};
247  template <> struct is_integral<bool> : true_type {};
248  template <> struct is_integral<char> : true_type {};
249  template <> struct is_integral<unsigned char> : true_type {};
250  template <> struct is_integral<signed char> : true_type {};
251  template <> struct is_integral<wchar_t> : true_type {};
252  template <> struct is_integral<short> : true_type {};
253  template <> struct is_integral<unsigned short> : true_type {};
254  template <> struct is_integral<int> : true_type {};
255  template <> struct is_integral<unsigned int> : true_type {};
256  template <> struct is_integral<long> : true_type {};
257  template <> struct is_integral<unsigned long> : true_type {};
258  template <> struct is_integral<long long> : true_type {};
259  template <> struct is_integral<unsigned long long> : true_type {};
260  template <typename T> struct is_integral<const T> : is_integral<T> {};
261  template <typename T> struct is_integral<volatile T> : is_integral<T> {};
262  template <typename T> struct is_integral<const volatile T> : is_integral<T> {};
263 
264 #if ETL_CPP17_SUPPORTED
265  template <typename T>
266  inline constexpr bool is_integral_v = is_integral<T>::value;
267 #endif
268 
269  //***************************************************************************
271  template <typename T> struct is_signed : false_type {};
272  template <> struct is_signed<char> : integral_constant<bool, (char(255) < 0)> {};
273  template <> struct is_signed<wchar_t> : public etl::integral_constant<bool, static_cast<bool>(wchar_t(-1) < wchar_t(0))> {};
274  template <> struct is_signed<signed char> : true_type {};
275  template <> struct is_signed<short> : true_type {};
276  template <> struct is_signed<int> : true_type {};
277  template <> struct is_signed<long> : true_type {};
278  template <> struct is_signed<long long> : true_type {};
279  template <> struct is_signed<float> : true_type {};
280  template <> struct is_signed<double> : true_type {};
281  template <> struct is_signed<long double> : true_type {};
282  template <typename T> struct is_signed<const T> : is_signed<T> {};
283  template <typename T> struct is_signed<volatile T> : is_signed<T> {};
284  template <typename T> struct is_signed<const volatile T> : is_signed<T> {};
285 
286 #if ETL_CPP17_SUPPORTED
287  template <typename T>
288  inline constexpr bool is_signed_v = is_signed<T>::value;
289 #endif
290 
291  //***************************************************************************
293  template <typename T> struct is_unsigned : false_type {};
294  template <> struct is_unsigned<bool> : true_type {};
295  template <> struct is_unsigned<char> : integral_constant<bool, (char(255) > 0)> {};
296  template <> struct is_unsigned<unsigned char> : true_type {};
297  template <> struct is_unsigned<wchar_t> : public etl::integral_constant<bool, (wchar_t(-1) > wchar_t(0))> {};
298  template <> struct is_unsigned<unsigned short> : true_type {};
299  template <> struct is_unsigned<unsigned int> : true_type {};
300  template <> struct is_unsigned<unsigned long> : true_type {};
301  template <> struct is_unsigned<unsigned long long> : true_type {};
302  template <typename T> struct is_unsigned<const T> : is_unsigned<T> {};
303  template <typename T> struct is_unsigned<volatile T> : is_unsigned<T> {};
304  template <typename T> struct is_unsigned<const volatile T> : is_unsigned<T> {};
305 
306 #if ETL_CPP17_SUPPORTED
307  template <typename T>
308  inline constexpr bool is_unsigned_v = is_unsigned<T>::value;
309 #endif
310 
311  //***************************************************************************
313  template <typename T> struct is_floating_point : false_type {};
314  template <> struct is_floating_point<float> : true_type {};
315  template <> struct is_floating_point<double> : true_type {};
316  template <> struct is_floating_point<long double> : true_type {};
317  template <typename T> struct is_floating_point<const T> : is_floating_point<T> {};
318  template <typename T> struct is_floating_point<volatile T> : is_floating_point<T> {};
319  template <typename T> struct is_floating_point<const volatile T> : is_floating_point<T> {};
320 
321 #if ETL_CPP17_SUPPORTED
322  template <typename T>
323  inline constexpr bool is_floating_point_v = is_floating_point<T>::value;
324 #endif
325 
326  //***************************************************************************
328  template <typename T1, typename T2> struct is_same : public false_type {};
329  template <typename T> struct is_same<T, T> : public true_type {};
330 
331 #if ETL_CPP17_SUPPORTED
332  template <typename T1, typename T2>
333  inline constexpr bool is_same_v = is_same<T1, T2>::value;
334 #endif
335 
336  //***************************************************************************
338  template<typename T> struct is_void : false_type {};
339  template<> struct is_void<void> : true_type {};
340 
341 #if ETL_CPP17_SUPPORTED
342  template <typename T>
343  inline constexpr bool is_void_v = is_void<T>::value;
344 #endif
345 
346  //***************************************************************************
348  template<typename T> struct is_arithmetic : integral_constant<bool, is_integral<T>::value || is_floating_point<T>::value> {};
349 
350 #if ETL_CPP17_SUPPORTED
351  template <typename T>
352  inline constexpr bool is_arithmetic_v = is_arithmetic<T>::value;
353 #endif
354 
355  //***************************************************************************
357  template <typename T> struct is_fundamental : integral_constant<bool, is_arithmetic<T>::value || is_void<T>::value> {};
358 
359 #if ETL_CPP17_SUPPORTED
360  template <typename T>
361  inline constexpr bool is_fundamental_v = is_fundamental<T>::value;
362 #endif
363 
364  //***************************************************************************
366  template <typename T> struct is_compound : integral_constant<bool, !is_fundamental<T>::value> {};
367 
368 #if ETL_CPP17_SUPPORTED
369  template <typename T>
370  inline constexpr bool is_compound_v = is_compound<T>::value;
371 #endif
372 
373  //***************************************************************************
375  template <typename T> struct is_array : false_type {};
376  template <typename T> struct is_array<T[]> : true_type {};
377  template <typename T, size_t MAXN> struct is_array<T[MAXN]> : true_type {};
378 
379 #if ETL_CPP17_SUPPORTED
380  template <typename T>
381  inline constexpr bool is_array_v = is_array<T>::value;
382 #endif
383 
384  //***************************************************************************
386  template<typename T> struct is_pointer_helper : false_type {};
387  template<typename T> struct is_pointer_helper<T*> : true_type {};
388  template<typename T> struct is_pointer : is_pointer_helper<typename remove_cv<T>::type> {};
389 
390 #if ETL_CPP17_SUPPORTED
391  template <typename T>
392  inline constexpr bool is_pointer_v = is_pointer<T>::value;
393 #endif
394 
395  //***************************************************************************
397  template<typename T> struct is_reference_helper : false_type {};
398  template<typename T> struct is_reference_helper<T&> : true_type {};
399  template<typename T> struct is_reference : is_reference_helper<typename remove_cv<T>::type> {};
400 
401 #if ETL_CPP17_SUPPORTED
402  template <typename T>
403  inline constexpr bool is_reference_v = is_reference<T>::value;
404 #endif
405 
406  //***************************************************************************
408  template<typename T> struct is_lvalue_reference_helper : false_type {};
409  template<typename T> struct is_lvalue_reference_helper<T&> : true_type {};
410  template<typename T> struct is_lvalue_reference : is_lvalue_reference_helper<typename remove_cv<T>::type> {};
411 
412 #if ETL_CPP17_SUPPORTED
413  template <typename T>
414  inline constexpr bool is_lvalue_reference_v = etl::is_lvalue_reference<T>::value;
415 #endif
416 
417 #if ETL_CPP11_SUPPORTED
418  //***************************************************************************
420  template<typename T> struct is_rvalue_reference_helper : false_type {};
421  template<typename T> struct is_rvalue_reference_helper<T&&> : true_type {};
422  template<typename T> struct is_rvalue_reference : is_rvalue_reference_helper<typename remove_cv<T>::type> {};
423 
424 #if ETL_CPP17_SUPPORTED
425  template <typename T>
426  inline constexpr bool is_rvalue_reference_v = etl::is_rvalue_reference<T>::value;
427 #endif
428 #endif
429 
430  //***************************************************************************
433  template <typename T> struct is_pod : etl::integral_constant<bool, etl::is_fundamental<T>::value || etl::is_pointer<T>::value> {};
434 
435 #if ETL_CPP17_SUPPORTED
436  template <typename T>
437  inline constexpr bool is_pod_v = etl::is_pod<T>::value;
438 #endif
439 
440  //***************************************************************************
443  template <typename T> struct is_trivially_constructible : etl::is_pod<T> {};
444 
445 #if ETL_CPP17_SUPPORTED
446  template <typename T>
447  inline constexpr bool is_trivially_constructible_v = etl::is_trivially_constructible<T>::value;
448 #endif
449 
450  //***************************************************************************
453  template <typename T> struct is_trivially_copy_constructible : etl::is_pod<T> {};
454 
455 #if ETL_CPP17_SUPPORTED
456  template <typename T>
457  inline constexpr bool is_trivially_copy_constructible_v = etl::is_trivially_copy_constructible<T>::value;
458 #endif
459 
460  //***************************************************************************
463  template <typename T> struct is_trivially_destructible : etl::is_pod<T> {};
464 
465 #if ETL_CPP17_SUPPORTED
466  template <typename T>
467  inline constexpr bool is_trivially_destructible_v = etl::is_trivially_destructible<T>::value;
468 #endif
469 
470  //***************************************************************************
473  template <typename T> struct is_trivially_copy_assignable : etl::is_pod<T> {};
474 
475 #if ETL_CPP17_SUPPORTED
476  template <typename T>
477  inline constexpr bool is_trivially_copy_assignable_v = etl::is_trivially_copy_assignable<T>::value;
478 #endif
479 
480  //***************************************************************************
483  template <typename T> struct is_trivially_copyable : etl::is_pod<T> {};
484 
485 #if ETL_CPP17_SUPPORTED
486  template <typename T>
487  inline constexpr bool is_trivially_copyable_v = etl::is_trivially_copyable<T>::value;
488 #endif
489 
490  //***************************************************************************
492  template <bool B, typename T, typename F> struct conditional { typedef T type; };
493  template <typename T, typename F> struct conditional<false, T, F> { typedef F type; };
494 
495  //***************************************************************************
497  template <typename T> struct make_signed { typedef T type; };
498  template <> struct make_signed<char> { typedef signed char type; };
499  template <> struct make_signed<unsigned char> { typedef signed char type; };
500 
501  template <> struct make_signed<wchar_t>
502  {
503  typedef etl::conditional<sizeof(wchar_t) == sizeof(int16_t),
504  int16_t,
505  etl::conditional<sizeof(wchar_t) == sizeof(int32_t),
506  int32_t,
507  void>::type>::type type;
508  };
509 
510  template <> struct make_signed<unsigned short> { typedef short type; };
511  template <> struct make_signed<unsigned int> { typedef int type; };
512  template <> struct make_signed<unsigned long> { typedef long type; };
513  template <> struct make_signed<unsigned long long> { typedef long long type; };
514  template <typename T> struct make_signed<const T> : add_const<typename make_signed<T>::type> {};
515  template <typename T> struct make_signed<volatile T> : add_volatile<typename make_signed<T>::type> {};
516  template <typename T> struct make_signed<const volatile T> : add_const<typename add_volatile<typename make_signed<T>::type>::type> {};
517 
518 #if ETL_CPP14_SUPPORTED
519  template <typename T>
520  using make_signed_t = typename make_signed<T>::type;
521 #endif
522 
523  //***************************************************************************
525  template <typename T> struct make_unsigned { typedef T type; };
526  template <> struct make_unsigned<char> { typedef unsigned char type; };
527  template <> struct make_unsigned<signed char> { typedef unsigned char type; };
528  template <> struct make_unsigned<short> { typedef unsigned short type; };
529 
530  template <> struct make_unsigned<wchar_t>
531  {
532  typedef etl::conditional<sizeof(wchar_t) == sizeof(uint16_t),
533  uint16_t,
534  etl::conditional<sizeof(wchar_t) == sizeof(uint32_t),
535  uint32_t,
536  void>::type>::type type;
537  };
538 
539  template <> struct make_unsigned<int> { typedef unsigned int type; };
540  template <> struct make_unsigned<long> { typedef unsigned long type; };
541  template <> struct make_unsigned<long long> { typedef unsigned long long type; };
542  template <typename T> struct make_unsigned<const T> : add_const<typename make_unsigned<T>::type> {};
543  template <typename T> struct make_unsigned<volatile T> : add_volatile<typename make_unsigned<T>::type> {};
544  template <typename T> struct make_unsigned<const volatile T> : add_const<typename add_volatile<typename make_unsigned<T>::type>::type> {};
545 
546 #if ETL_CPP14_SUPPORTED
547  template <typename T>
548  using make_unsigned_t = typename make_unsigned<T>::type;
549 #endif
550 
551  //***************************************************************************
553  template <bool B, typename T = void> struct enable_if {};
554  template <typename T> struct enable_if<true, T> { typedef T type; };
555 
556 #if ETL_CPP14_SUPPORTED
557  template <bool B, typename T = void>
558  using enable_if_t = typename enable_if<B, T>::type;
559 #endif
560 
561  //***************************************************************************
563  template <typename T, size_t MAXN = 0U>
564  struct extent : integral_constant<size_t, 0U> {};
565 
566  template <typename T>
567  struct extent<T[], 0> : integral_constant<size_t, 0U> {};
568 
569  template <typename T, size_t MAXN>
570  struct extent<T[], MAXN> : integral_constant<size_t, extent<T, MAXN - 1>::value> {};
571 
572  template <typename T, size_t MAXN>
573  struct extent<T[MAXN], 0> : integral_constant<size_t, MAXN> {};
574 
575  template <typename T, size_t I, size_t MAXN>
576  struct extent<T[I], MAXN> : integral_constant<size_t, extent<T, MAXN - 1>::value> {};
577 
578 #if ETL_CPP17_SUPPORTED
579  template <typename T, size_t N = 0U>
580  inline constexpr size_t extent_v = extent<T, N>::value;
581 #endif
582 
583  //***************************************************************************
585  template <typename T> struct remove_extent { typedef T type; };
586  template <typename T> struct remove_extent<T[]> { typedef T type; };
587  template <typename T, size_t MAXN> struct remove_extent<T[MAXN]> { typedef T type; };
588 
589 #if ETL_CPP14_SUPPORTED
590  template <typename T>
591  using remove_extent_t = typename remove_extent<T>::type;
592 #endif
593 
594  //***************************************************************************
596  template <typename T> struct remove_all_extents { typedef T type; };
597  template <typename T> struct remove_all_extents<T[]> { typedef typename remove_all_extents<T>::type type; };
598  template <typename T, size_t MAXN> struct remove_all_extents<T[MAXN]> { typedef typename remove_all_extents<T>::type type; };
599 
600 #if ETL_CPP14_SUPPORTED
601  template <typename T>
602  using remove_all_extents_t = typename remove_all_extents<T>::type;
603 #endif
604 
605  //***************************************************************************
607  template <typename T>struct rank : integral_constant<size_t, 0> {};
608  template <typename T> struct rank<T[]> : public integral_constant<size_t, rank<T>::value + 1> {};
609  template <typename T, size_t MAXN> struct rank<T[MAXN]> : public integral_constant<size_t, rank<T>::value + 1> {};
610 
611 #if ETL_CPP17_SUPPORTED
612  template <typename T>
613  inline constexpr size_t rank_v = rank<T>::value;
614 #endif
615 
616  //***************************************************************************
618  template <typename T>
619  struct decay
620  {
621  typedef typename etl::remove_reference<T>::type U;
623  typename etl::remove_extent<U>::type*,
624  typename etl::remove_cv<U>::type>::type type;
625  };
626 
627 #if ETL_CPP14_SUPPORTED
628  template <typename T>
629  using decay_t = typename decay<T>::type;
630 #endif
631 
632  //***************************************************************************
634  template<typename TBase,
635  typename TDerived,
637  struct is_base_of
638  {
639  private:
640 
641  template<typename T> struct dummy {};
642  struct internal: TDerived, dummy<int>{};
643 
644  static TBase* check(TBase*);
645  template<typename T> static char check(dummy<T>*);
646 
647  public:
648 
649  static const bool value = (sizeof(check((internal*)0)) == sizeof(TBase*));
650  };
651 
652  // For when TBase or TDerived is a fundamental type.
653  template<typename TBase, typename TDerived>
655  {
656  static const bool value = false;
657  };
658 
659 #if ETL_CPP17_SUPPORTED
660  template <typename T1, typename T2>
661  inline constexpr bool is_base_of_v = is_base_of<T1, T2>::value;
662 #endif
663 
664  //***************************************************************************
666  namespace private_type_traits
667  {
668  template <typename T> char test(int T::*); // Match for classes.
669 
670  struct dummy { char c[2]; };
671  template <typename T> dummy test(...); // Match for non-classes.
672  }
673 
674  template <typename T>
676 
677 #if ETL_CPP17_SUPPORTED
678  template <typename T>
679  inline constexpr bool is_class_v = is_class<T>::value;
680 #endif
681 
682  //***************************************************************************
684  template <typename T> struct add_lvalue_reference { typedef T& type; };
685  template <typename T> struct add_lvalue_reference<T&> { typedef T& type; };
686  template <> struct add_lvalue_reference<void> { typedef void type; };
687  template <> struct add_lvalue_reference<const void> { typedef const void type; };
688  template <> struct add_lvalue_reference<volatile void> { typedef volatile void type; };
689  template <> struct add_lvalue_reference<const volatile void> { typedef const volatile void type; };
690 
691 #if ETL_CPP14_SUPPORTED
692  template <typename T>
693  using add_lvalue_reference_t = typename etl::add_lvalue_reference<T>::type;
694 #endif
695 
696  //***************************************************************************
698 #if ETL_CPP11_SUPPORTED
699  template <typename T> struct add_rvalue_reference { using type = T && ; };
700  template <typename T> struct add_rvalue_reference<T&> { using type = T & ; };
701  template <> struct add_rvalue_reference<void> { using type = void; };
702  template <> struct add_rvalue_reference<const void> { using type = const void; };
703  template <> struct add_rvalue_reference<volatile void> { using type = volatile void; };
704  template <> struct add_rvalue_reference<const volatile void> { using type = const volatile void; };
705 #endif
706 
707 #if ETL_CPP14_SUPPORTED
708  template <typename T>
709  using add_rvalue_reference_t = typename etl::add_rvalue_reference<T>::type;
710 #endif
711 
712  //***************************************************************************
714 #if ETL_CPP11_SUPPORTED
715  template <typename T>
716  typename etl::add_rvalue_reference<T>::type declval() ETL_NOEXCEPT;
717 #endif
718 
719  //***************************************************************************
721 #if ETL_CPP11_SUPPORTED
722  namespace private_type_traits
723  {
724  template <typename>
725  using true_type_for = etl::true_type;
726 
727  template <typename T>
728  auto returnable(int)->true_type_for<T()>;
729 
730  template <typename>
731  auto returnable(...)->etl::false_type;
732 
733  template <typename TFrom, typename TTo>
734  auto nonvoid_convertible(int)->true_type_for<decltype(etl::declval<void(&)(TTo)>()(etl::declval<TFrom>()))
735  >;
736  template <typename, typename>
737  auto nonvoid_convertible(...)->etl::false_type;
738  }
739 
740 #if defined(ETL_COMPILER_ARM5)
741  template <typename TFrom, typename TTo>
742  struct is_convertible : etl::integral_constant<bool, __is_convertible_to(TFrom, TTo)> {};
743 #else
744  template <typename TFrom, typename TTo>
745  struct is_convertible : etl::integral_constant<bool, (decltype(private_type_traits::returnable<TTo>(0))::value &&
746  decltype(private_type_traits::nonvoid_convertible<TFrom, TTo>(0))::value) ||
747  (etl::is_void<TFrom>::value && etl::is_void<TTo>::value)> {};
748 #endif
749 #endif
750 
751 #if ETL_CPP17_SUPPORTED
752  template <typename TFrom, typename TTo >
753  inline constexpr bool is_convertible_v = etl::is_convertible<TFrom, TTo>::value;
754 #endif
755 
756  //***************************************************************************
759 #if ETL_CPP11_SUPPORTED && !defined(ETL_COMPILER_ARM5)
760  template <typename T> struct alignment_of : integral_constant<size_t, alignof(T)> { };
761 #elif defined(ETL_COMPILER_MICROSOFT)
762  template <typename T> struct alignment_of : integral_constant<size_t, size_t(__alignof(T))> {};
763 #elif defined(ETL_COMPILER_IAR) || defined(ETL_COMPILER_TI)
764  template <typename T> struct alignment_of : integral_constant<size_t, size_t(__ALIGNOF__(T))> {};
765 #else
766  template <typename T> struct alignment_of : integral_constant<size_t, size_t(__alignof__(T))> {};
767 #endif
768 
771  template <> struct alignment_of<void> : integral_constant <size_t, 0> {};
772 
773 #if ETL_CPP17_SUPPORTED
774  template <typename T>
775  inline constexpr size_t alignment_of_v = etl::alignment_of<T>::value;
776 #endif
777 
778 #else // Condition = ETL_USING_STL && ETL_CPP11_SUPPORTED
779 
780  //*****************************************************************************
781  // Traits are derived from the STL
782  //*****************************************************************************
783 
784  //***************************************************************************
787  template <typename T, const T VALUE>
788  struct integral_constant : std::integral_constant<T, VALUE> {};
789 
792  typedef integral_constant<bool, false> false_type;
793  typedef integral_constant<bool, true> true_type;
794 
795 #if ETL_CPP17_SUPPORTED
796  template <bool B>
797  using bool_constant = std::bool_constant<B>;
798 #else
799  template <bool B>
800  struct bool_constant : std::integral_constant<bool, B> { };
801 #endif
802 
803  //***************************************************************************
806 #if ETL_CPP17_SUPPORTED
807  template <typename T>
808  struct negation : std::negation<T>
809  {
810  };
811 
812  template <typename T>
813  inline constexpr bool negation_v = std::negation_v<T>;
814 #endif
815 
816  //***************************************************************************
819  template <typename T> struct remove_reference : std::remove_reference<T> {};
820 
821 #if ETL_CPP14_SUPPORTED
822  template <typename T>
823  using remove_reference_t = std::remove_reference_t<T>;
824 #endif
825 
826  //***************************************************************************
829  template <typename T> struct remove_pointer : std::remove_pointer<T> {};
830 
831 #if ETL_CPP14_SUPPORTED
832  template <typename T>
833  using remove_pointer_t = std::remove_pointer_t<T>;
834 #endif
835 
836  //***************************************************************************
839  template <typename T> struct add_pointer : std::add_pointer<T> {};
840 
841 #if ETL_CPP14_SUPPORTED
842  template <typename T>
843  using add_pointer_t = std::add_pointer_t<T>;
844 #endif
845 
846  //***************************************************************************
849  template <typename T> struct is_const : std::is_const<T> {};
850 
851 #if ETL_CPP17_SUPPORTED
852  template <typename T>
853  inline constexpr bool is_const_v = std::is_const_v<T>;
854 #endif
855 
856  //***************************************************************************
859  template <typename T> struct remove_const : std::remove_const<T> {};
860 
861 #if ETL_CPP14_SUPPORTED
862  template <typename T>
863  using remove_const_t = std::remove_const_t<T>;
864 #endif
865 
866  //***************************************************************************
869  template <typename T> struct add_const : std::add_const<T> {};
870 
871 #if ETL_CPP14_SUPPORTED
872  template <typename T>
873  using add_const_t = std::add_const_t<T>;
874 #endif
875 
876  //***************************************************************************
879  template <typename T> struct is_volatile : std::is_volatile<T> {};
880 
881 #if ETL_CPP17_SUPPORTED
882  template <typename T>
883  inline constexpr bool is_volatile_v = std::is_volatile_v<T>;
884 #endif
885 
886  //***************************************************************************
889  template <typename T> struct remove_volatile : std::remove_volatile<T> {};
890 
891 #if ETL_CPP14_SUPPORTED
892  template <typename T>
893  using remove_volatile_t = std::remove_volatile_t<T>;
894 #endif
895 
896  //***************************************************************************
899  template <typename T> struct add_volatile : std::add_volatile<T> {};
900 
901 #if ETL_CPP14_SUPPORTED
902  template <typename T>
903  using add_volatile_t = std::add_volatile_t<T>;
904 #endif
905 
906  //***************************************************************************
909  template <typename T> struct remove_cv : std::remove_cv<T> {};
910 
911 #if ETL_CPP14_SUPPORTED
912  template <typename T>
913  using remove_cv_t = std::remove_cv_t<T>;
914 #endif
915 
916  //***************************************************************************
919  template <typename T> struct add_cv : std::add_cv<T> {};
920 
921 #if ETL_CPP14_SUPPORTED
922  template <typename T>
923  using add_cv_t = std::add_cv_t<T>;
924 #endif
925 
926  //***************************************************************************
929  template <typename T> struct is_integral : std::is_integral<T> {};
930 
931 #if ETL_CPP17_SUPPORTED
932  template <typename T>
933  inline constexpr bool is_integral_v = std::is_integral_v<T>;
934 #endif
935 
936  //***************************************************************************
939  template <typename T> struct is_signed : std::is_signed<T> {};
940 
941 #if ETL_CPP17_SUPPORTED
942  template <typename T>
943  inline constexpr bool is_signed_v = std::is_signed_v<T>;
944 #endif
945 
946  //***************************************************************************
949  template <typename T> struct is_unsigned : std::is_unsigned<T> {};
950 
951 #if ETL_CPP17_SUPPORTED
952  template <typename T>
953  inline constexpr bool is_unsigned_v = std::is_unsigned_v<T>;
954 #endif
955 
956  //***************************************************************************
959  template <typename T> struct is_floating_point : std::is_floating_point<T> {};
960 
961 #if ETL_CPP17_SUPPORTED
962  template <typename T>
963  inline constexpr bool is_floating_point_v = std::is_floating_point_v<T>;
964 #endif
965 
966  //***************************************************************************
969  template <typename T1, typename T2> struct is_same : std::is_same<T1, T2> {};
970 
971 #if ETL_CPP17_SUPPORTED
972  template <typename T1, typename T2>
973  inline constexpr bool is_same_v = std::is_same_v<T1, T2>;
974 #endif
975 
976  //***************************************************************************
979  template<typename T> struct is_void : std::is_void<T> {};
980 
981 #if ETL_CPP17_SUPPORTED
982  template <typename T>
983  inline constexpr bool is_void_v = std::is_void_v<T>;
984 #endif
985 
986  //***************************************************************************
989  template<typename T> struct is_arithmetic : std::is_arithmetic<T> {};
990 
991 #if ETL_CPP17_SUPPORTED
992  template <typename T>
993  inline constexpr bool is_arithmetic_v = std::is_arithmetic_v<T>;
994 #endif
995 
996  //***************************************************************************
999  template <typename T> struct is_fundamental : std::is_fundamental<T> {};
1000 
1001 #if ETL_CPP17_SUPPORTED
1002  template <typename T>
1003  inline constexpr bool is_fundamental_v = std::is_fundamental_v<T>;
1004 #endif
1005 
1006  //***************************************************************************
1009  template <typename T> struct is_compound : std::is_compound<T> {};
1010 
1011 #if ETL_CPP17_SUPPORTED
1012  template <typename T>
1013  inline constexpr bool is_compound_v = std::is_compound_v<T>;
1014 #endif
1015 
1016  //***************************************************************************
1019  template <typename T> struct is_array : std::is_array<T> {};
1020 
1021 #if ETL_CPP17_SUPPORTED
1022  template <typename T>
1023  inline constexpr bool is_array_v = std::is_array_v<T>;
1024 #endif
1025 
1026  //***************************************************************************
1029  template<typename T> struct is_pointer : std::is_pointer<T> {};
1030 
1031 #if ETL_CPP17_SUPPORTED
1032  template <typename T>
1033  inline constexpr bool is_pointer_v = std::is_pointer_v<T>;
1034 #endif
1035 
1036  //***************************************************************************
1039  template<typename T> struct is_reference : std::is_reference<T> {};
1040 
1041 #if ETL_CPP17_SUPPORTED
1042  template <typename T>
1043  inline constexpr bool is_reference_v = std::is_reference_v<T>;
1044 #endif
1045 
1046  //***************************************************************************
1049  template<typename T> struct is_lvalue_reference : std::is_lvalue_reference<T> {};
1050 
1051 #if ETL_CPP17_SUPPORTED
1052  template <typename T>
1053  inline constexpr bool is_lvalue_reference_v = std::is_lvalue_reference_v<T>;
1054 #endif
1055 
1056  //***************************************************************************
1059 #if ETL_CPP11_SUPPORTED
1060  template<typename T> struct is_rvalue_reference : std::is_rvalue_reference<T> {};
1061 
1062 #if ETL_CPP17_SUPPORTED
1063  template <typename T>
1064  inline constexpr bool is_rvalue_reference_v = std::is_rvalue_reference_v<T>;
1065 #endif
1066 #endif
1067 
1068  //***************************************************************************
1071  template <typename T>
1072  struct is_pod : std::integral_constant<bool, std::is_standard_layout<T>::value && std::is_trivial<T>::value> {};
1073 
1074 #if ETL_CPP17_SUPPORTED
1075  template <typename T>
1076  inline constexpr bool is_pod_v = std::is_standard_layout_v<T> && std::is_trivial_v<T>;
1077 #endif
1078 
1079 #if defined(ETL_COMPILER_GCC)
1080  #if ETL_COMPILER_VERSION >= 5
1081  #define ETL_GCC_V5_TYPE_TRAITS_SUPPORTED
1082  #endif
1083 #endif
1084 
1085 #if !defined(ARDUINO) && ETL_NOT_USING_STLPORT && defined(ETL_GCC_V5_TYPE_TRAITS_SUPPORTED)
1086  //***************************************************************************
1089  template <typename T> struct is_trivially_constructible : std::is_trivially_constructible<T> {};
1090 
1091 #if ETL_CPP17_SUPPORTED
1092  template <typename T>
1093  inline constexpr bool is_trivially_constructible_v = std::is_trivially_constructible_v<T>;
1094 #endif
1095 
1096  //***************************************************************************
1099  template <typename T> struct is_trivially_copy_constructible : std::is_trivially_copy_constructible<T> {};
1100 
1101 #if ETL_CPP17_SUPPORTED
1102  template <typename T>
1103  inline constexpr bool is_trivially_copy_constructible_v = std::is_trivially_copy_constructible_v<T>;
1104 #endif
1105 
1106  //***************************************************************************
1109  template <typename T> struct is_trivially_destructible : std::is_trivially_destructible<T> {};
1110 
1111 #if ETL_CPP17_SUPPORTED
1112  template <typename T>
1113  inline constexpr bool is_trivially_destructible_v = std::is_trivially_destructible_v<T>;
1114 #endif
1115 
1116  //***************************************************************************
1119  template <typename T> struct is_trivially_copy_assignable : std::is_trivially_copy_assignable<T> {};
1120 
1121 #if ETL_CPP17_SUPPORTED
1122  template <typename T>
1123  inline constexpr bool is_trivially_copy_assignable_v = std::is_trivially_copy_assignable_v<T>;
1124 #endif
1125 
1126  //***************************************************************************
1129  template <typename T> struct is_trivially_copyable : std::is_trivially_copyable<T> {};
1130 
1131 #if ETL_CPP17_SUPPORTED
1132  template <typename T>
1133  inline constexpr bool is_trivially_copyable_v = std::is_trivially_copyable_v<T>;
1134 #endif
1135 #else
1136  //***************************************************************************
1139  template <typename T> struct is_trivially_constructible : std::is_pod<T> {};
1140 
1141  #if ETL_CPP17_SUPPORTED
1142  template <typename T>
1143  inline constexpr bool is_trivially_constructible_v = std::is_pod_v<T>;
1144  #endif
1145 
1146  //***************************************************************************
1149  template <typename T> struct is_trivially_copy_constructible : std::is_pod<T> {};
1150 
1151  #if ETL_CPP17_SUPPORTED
1152  template <typename T>
1153  inline constexpr bool is_trivially_copy_constructible_v = std::is_pod_v<T>;
1154  #endif
1155 
1156  //***************************************************************************
1159  template <typename T> struct is_trivially_destructible : std::is_pod<T> {};
1160 
1161  #if ETL_CPP17_SUPPORTED
1162  template <typename T>
1163  inline constexpr bool is_trivially_destructible_v = std::is_pod_v<T>;
1164  #endif
1165 
1166  //***************************************************************************
1169  template <typename T> struct is_trivially_copy_assignable : std::is_pod<T> {};
1170 
1171  #if ETL_CPP17_SUPPORTED
1172  template <typename T>
1173  inline constexpr bool is_trivially_copy_assignable_v = std::is_pod_v<T>;
1174  #endif
1175 
1176  //***************************************************************************
1179  template <typename T> struct is_trivially_copyable : std::is_pod<T> {};
1180 
1181  #if ETL_CPP17_SUPPORTED
1182  template <typename T>
1183  inline constexpr bool is_trivially_copyable_v = std::is_pod_v<T>;
1184  #endif
1185 #endif
1186 
1187  //***************************************************************************
1190  template <bool B, typename T, typename F> struct conditional { typedef T type; };
1191  template <typename T, typename F> struct conditional<false, T, F> { typedef F type; };
1192 
1193  //***************************************************************************
1196  template <typename T> struct make_signed : std::make_signed<T> {};
1197 
1198 #if ETL_CPP14_SUPPORTED
1199  template <typename T>
1200  using make_signed_t = std::make_signed_t<T>;
1201 #endif
1202 
1203  //***************************************************************************
1206  template <typename T> struct make_unsigned : std::make_unsigned<T> {};
1207 
1208 #if ETL_CPP14_SUPPORTED
1209  template <typename T>
1210  using make_unsigned_t = std::make_unsigned_t<T>;
1211 #endif
1212 
1213  //***************************************************************************
1216  template <bool B, typename T = void> struct enable_if : std::enable_if<B, T> {};
1217 
1218 #if ETL_CPP14_SUPPORTED
1219  template <bool B, typename T = void>
1220  using enable_if_t = std::enable_if_t<B, T>;
1221 #endif
1222 
1223  //***************************************************************************
1226  template <typename T, size_t MAXN = 0U>
1227  struct extent : std::extent<T, MAXN> {};
1228 
1229 #if ETL_CPP17_SUPPORTED
1230  template <typename T, size_t MAXN = 0U>
1231  inline constexpr size_t extent_v = std::extent_v<T, MAXN>;
1232 #endif
1233 
1234  //***************************************************************************
1237  template <typename T> struct remove_extent : std::remove_extent<T> { };
1238 
1239 #if ETL_CPP14_SUPPORTED
1240  template <typename T>
1241  using remove_extent_t = std::remove_extent_t<T>;
1242 #endif
1243 
1244  //***************************************************************************
1247  template <typename T> struct remove_all_extents : std::remove_all_extents<T> { };
1248 
1249 #if ETL_CPP14_SUPPORTED
1250  template <typename T>
1251  using remove_all_extents_t = std::remove_all_extents_t<T>;
1252 #endif
1253 
1254  //***************************************************************************
1257  template <typename T>struct rank : std::rank<T> {};
1258 
1259 #if ETL_CPP17_SUPPORTED
1260  template <typename T>
1261  inline constexpr size_t rank_v = std::rank_v<T>;
1262 #endif
1263 
1264  //***************************************************************************
1267  template <typename T> struct decay : std::decay<T> {};
1268 
1269 #if ETL_CPP14_SUPPORTED
1270  template <typename T>
1271  using decay_t = std::decay_t<T>;
1272 #endif
1273 
1274  //***************************************************************************
1277  template<typename TBase, typename TDerived> struct is_base_of : std::is_base_of<TBase, TDerived> {};
1278 
1279 #if ETL_CPP17_SUPPORTED
1280  template <typename TBase, typename TDerived>
1281  inline constexpr bool is_base_of_v = std::is_base_of_v<TBase, TDerived>;
1282 #endif
1283 
1284  //***************************************************************************
1286  template <typename T> struct is_class : std::is_class<T>{};
1287 
1288 #if ETL_CPP17_SUPPORTED
1289  template <typename T>
1290  inline constexpr bool is_class_v = is_class<T>::value;
1291 #endif
1292 
1293  //***************************************************************************
1295  template <typename T> struct add_lvalue_reference : std::add_lvalue_reference<T> {};
1296 
1297 #if ETL_CPP14_SUPPORTED
1298  template <typename T>
1299  using add_lvalue_reference_t = std::add_lvalue_reference_t<T>;
1300 #endif
1301 
1302  //***************************************************************************
1304 #if ETL_CPP11_SUPPORTED
1305  template <typename T> struct add_rvalue_reference : std::add_rvalue_reference<T> {};
1306 #endif
1307 
1308 #if ETL_CPP14_SUPPORTED
1309  template <typename T>
1310  using add_rvalue_reference_t = std::add_rvalue_reference_t<T>;
1311 #endif
1312 
1313  //***************************************************************************
1315 #if ETL_CPP11_SUPPORTED
1316  template <typename T>
1317  typename std::add_rvalue_reference<T>::type declval() ETL_NOEXCEPT;
1318 #endif
1319 
1320  //***************************************************************************
1323 #if ETL_CPP11_SUPPORTED
1324  template <typename TFrom, typename TTo>
1325  struct is_convertible : std::is_convertible<TFrom, TTo> {};
1326 #endif
1327 
1328 #if ETL_CPP17_SUPPORTED
1329  template <typename TFrom, typename TTo>
1330  inline constexpr bool is_convertible_v = std::is_convertible_v<TFrom, TTo>;
1331 #endif
1332 
1333  //***************************************************************************
1336  template <typename T> struct alignment_of : std::alignment_of<T> {};
1337  template <> struct alignment_of<void> : std::integral_constant<size_t, 0> {};
1338 
1339 #if ETL_CPP17_SUPPORTED
1340  template <typename T>
1341  inline constexpr size_t alignment_of_v = std::alignment_of_v<T>;
1342 #endif
1343 
1344 #endif // Condition = ETL_USING_STL && ETL_CPP11_SUPPORTED
1345 
1346  //***************************************************************************
1347  // ETL extended type traits.
1348  //***************************************************************************
1349 
1350  //***************************************************************************
1352  // /\ingroup type_traits
1353  template <bool B, typename T, T TRUE_VALUE, T FALSE_VALUE>
1354  struct conditional_integral_constant;
1355 
1356  template <typename T, T TRUE_VALUE, T FALSE_VALUE>
1357  struct conditional_integral_constant<true, T, TRUE_VALUE, FALSE_VALUE>
1358  {
1359  ETL_STATIC_ASSERT(etl::is_integral<T>::value, "Not an integral type");
1360  static const T value = TRUE_VALUE;
1361  };
1362 
1363  template <typename T, T TRUE_VALUE, T FALSE_VALUE>
1364  struct conditional_integral_constant<false, T, TRUE_VALUE, FALSE_VALUE>
1365  {
1366  ETL_STATIC_ASSERT(etl::is_integral<T>::value, "Not an integral type");
1367  static const T value = FALSE_VALUE;
1368  };
1369 
1370 
1371 #if ETL_CPP11_SUPPORTED
1372  //***************************************************************************
1375  template <typename T, typename T1, typename... TRest>
1376  struct is_one_of
1377  {
1378  static const bool value = etl::is_same<T, T1>::value ||
1379  etl::is_one_of<T, TRest...>::value;
1380  };
1381 
1382  template <typename T, typename T1>
1383  struct is_one_of<T, T1>
1384  {
1385  static const bool value = etl::is_same<T, T1>::value;
1386  };
1387 #else
1388  //***************************************************************************
1391  template <typename T,
1392  typename T1, typename T2 = void, typename T3 = void, typename T4 = void,
1393  typename T5 = void, typename T6 = void, typename T7 = void, typename T8 = void,
1394  typename T9 = void, typename T10 = void, typename T11 = void, typename T12 = void,
1395  typename T13 = void, typename T14 = void, typename T15 = void, typename T16 = void>
1396  struct is_one_of
1397  {
1398  static const bool value =
1415  };
1416 #endif
1417 
1418 #if ETL_CPP17_SUPPORTED
1419  template <typename T, typename... TRest>
1420  inline constexpr bool is_one_of_v = etl::is_one_of<T, TRest...>::value;
1421 #endif
1422 
1423  //***************************************************************************
1426 
1427  // Default.
1428  template <typename T>
1429  struct types
1430  {
1431  private:
1432 
1433  typedef typename etl::remove_reference<typename etl::remove_cv<T>::type>::type type_t;
1434 
1435  public:
1436 
1437  typedef type_t type;
1438  typedef type_t& reference;
1439  typedef const type_t& const_reference;
1440  typedef type_t* pointer;
1441  typedef const type_t* const_pointer;
1442  typedef const type_t* const const_pointer_const;
1443 
1444 #if ETL_CPP11_SUPPORTED
1445  typedef type_t&& rvalue_reference;
1446 #endif
1447  };
1448 
1449  // Pointers.
1450  template <typename T>
1451  struct types<T*>
1452  {
1453  private:
1454 
1455  typedef typename etl::remove_reference<typename etl::remove_cv<T>::type>::type type_t;
1456 
1457  public:
1458 
1459  typedef type_t type;
1460  typedef type_t& reference;
1461  typedef const type_t& const_reference;
1462  typedef type_t* pointer;
1463  typedef const type_t* const_pointer;
1464  typedef const type_t* const const_pointer_const;
1465 
1466 #if ETL_CPP11_SUPPORTED
1467  typedef type_t&& rvalue_reference;
1468 #endif
1469  };
1470 
1471  // Pointers.
1472  template <typename T>
1473  struct types<T* const>
1474  {
1475  private:
1476 
1477  typedef typename etl::remove_reference<typename etl::remove_cv<T>::type>::type type_t;
1478 
1479  public:
1480 
1481  typedef type_t type;
1482  typedef type_t& reference;
1483  typedef const type_t& const_reference;
1484  typedef type_t* pointer;
1485  typedef const type_t* const_pointer;
1486  typedef const type_t* const const_pointer_const;
1487 
1488 #if ETL_CPP11_SUPPORTED
1489  typedef type_t&& rvalue_reference;
1490 #endif
1491  };
1492 
1493  // References.
1494  template <typename T>
1495  struct types<T&>
1496  {
1497  private:
1498 
1499  typedef typename etl::remove_reference<typename etl::remove_cv<T>::type>::type type_t;
1500 
1501  public:
1502 
1503  typedef type_t type;
1504  typedef type_t& reference;
1505  typedef const type_t& const_reference;
1506  typedef type_t* pointer;
1507  typedef const type_t* const_pointer;
1508  typedef const type_t* const const_pointer_const;
1509 
1510 #if ETL_CPP11_SUPPORTED
1511  typedef type_t&& rvalue_reference;
1512 #endif
1513  };
1514 
1515 #if ETL_CPP11_SUPPORTED
1516  // rvalue References.
1517  template <typename T>
1518  struct types<T&&>
1519  {
1520  private:
1521 
1522  typedef typename etl::remove_reference<typename etl::remove_cv<T>::type>::type type_t;
1523 
1524  public:
1525 
1526  typedef type_t type;
1527  typedef type_t& reference;
1528  typedef const type_t& const_reference;
1529  typedef type_t* pointer;
1530  typedef const type_t* const_pointer;
1531  typedef const type_t* const const_pointer_const;
1532 
1533 #if ETL_CPP11_SUPPORTED
1534  typedef type_t&& rvalue_reference;
1535 #endif
1536  };
1537 #endif
1538 
1539 #if ETL_CPP11_SUPPORTED
1540  template <typename T>
1541  using types_t = typename types<T>::type;
1542 
1543  template <typename T>
1544  using types_r = typename types<T>::reference;
1545 
1546  template <typename T>
1547  using types_cr = typename types<T>::const_reference;
1548 
1549  template <typename T>
1550  using types_rr = typename types<T>::rvalue_reference;
1551 
1552  template <typename T>
1553  using types_p = typename types<T>::pointer;
1554 
1555  template <typename T>
1556  using types_cp = typename types<T>::const_pointer;
1557 
1558  template <typename T>
1559  using types_cpc = typename types<T>::const_pointer_const;
1560 #endif
1561 
1562  //***************************************************************************
1565  template <typename T> struct size_of : etl::integral_constant<size_t, sizeof(T)> {};
1566  template <> struct size_of<void> : etl::integral_constant<size_t, 1U> {};
1567 
1568 #if ETL_CPP17_SUPPORTED
1569  template <typename T>
1570  inline constexpr size_t size_of_v = etl::size_of<T>::value;
1571 #endif
1572 
1573 #if ETL_CPP11_SUPPORTED
1574  //***************************************************************************
1576  template <typename T, typename T1, typename... TRest>
1577  struct are_all_same
1578  {
1579  static const bool value = etl::is_same<T, T1>::value &&
1580  etl::are_all_same<T, TRest...>::value;
1581  };
1582 
1583  template <typename T, typename T1>
1584  struct are_all_same<T, T1>
1585  {
1586  static const bool value = etl::is_same<T, T1>::value;
1587  };
1588 #endif
1589 
1590 #if ETL_CPP17_SUPPORTED
1591  template <typename T, typename T1, typename... TRest>
1592  inline constexpr bool are_all_same_v = are_all_same<T, T1, TRest...>::value;
1593 #endif
1594 }
1595 
1596 #endif // ETL_TYPE_TRAITS_INCLUDED
Definition: constant.h:45
integral_constant< bool, false > false_type
integral_constant specialisations
Definition: type_traits_generator.h:804
add_const
Definition: type_traits_generator.h:881
add_pointer
Definition: type_traits_generator.h:851
add_volatile
Definition: type_traits_generator.h:911
add_rvalue_reference
Definition: type_traits_generator.h:1348
conditional
Definition: type_traits_generator.h:1202
decay
Definition: type_traits_generator.h:1279
enable_if
Definition: type_traits_generator.h:1228
extent
Definition: type_traits_generator.h:1239
integral_constant
Definition: type_traits_generator.h:800
is_arithmetic
Definition: type_traits_generator.h:1001
is_array
Definition: type_traits_generator.h:1031
is_base_of
Definition: type_traits_generator.h:1289
is_const
Definition: type_traits_generator.h:861
is_floating_point
Definition: type_traits_generator.h:971
is_fundamental
Definition: type_traits_generator.h:1011
is_integral
Definition: type_traits_generator.h:941
is_lvalue_reference
Definition: type_traits_generator.h:1061
is_rvalue_reference
Definition: type_traits_generator.h:1084
is_pointer
Definition: type_traits_generator.h:1041
is_reference
Definition: type_traits_generator.h:1051
is_same
Definition: type_traits_generator.h:981
is_signed
Definition: type_traits_generator.h:951
is_trivially_constructible
Definition: type_traits_generator.h:1151
is_trivially_copy_assignable
Definition: type_traits_generator.h:1181
is_trivially_copy_constructible
Definition: type_traits_generator.h:1161
is_trivially_copyable
Definition: type_traits_generator.h:1191
is_trivially_destructible
Definition: type_traits_generator.h:1171
is_unsigned
Definition: type_traits_generator.h:961
is_void
Definition: type_traits_generator.h:991
is_volatile
Definition: type_traits_generator.h:891
make_signed
Definition: type_traits_generator.h:1208
make_unsigned
Definition: type_traits_generator.h:1218
rank
Definition: type_traits_generator.h:1269
remove_all_extents
Definition: type_traits_generator.h:1259
remove_const
Definition: type_traits_generator.h:871
remove_cv
Definition: type_traits_generator.h:921
remove_extent
Definition: type_traits_generator.h:1249
remove_pointer
Definition: type_traits_generator.h:841
negation
Definition: type_traits_generator.h:831
remove_volatile
Definition: type_traits_generator.h:901
Definition: absolute.h:37
Definition: type_traits.h:685
Definition: type_traits.h:687
Definition: type_traits.h:686
Definition: type_traits.h:688
Definition: type_traits_generator.h:812
Definition: type_traits.h:655
is_class
Definition: type_traits_generator.h:1298
is_lvalue_reference
Definition: type_traits.h:408
Definition: type_traits.h:1397
is_pointer
Definition: type_traits.h:386
is_reference
Definition: type_traits.h:397
negation
Definition: type_traits.h:114
Definition: type_traits.h:670
size_of
Definition: type_traits_generator.h:1572
A set of templates to allow related types to be derived.
Definition: type_traits_generator.h:1437
void add_pointer(const volatile void *value, TIString &str, const etl::basic_format_spec< TIString > &format, bool append)
Helper function for pointers.
Definition: to_string_helper.h:326