Embedded Template Library  1.0
type_traits_generator.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 /*[[[cog
32 import cog
33 cog.outl("#if 0")
34 ]]]*/
35 /*[[[end]]]*/
36 #error THIS HEADER IS A GENERATOR. DO NOT INCLUDE.
37 /*[[[cog
38 import cog
39 cog.outl("#endif")
40 ]]]*/
41 /*[[[end]]]*/
42 
43 /*[[[cog
44 import cog
45 cog.outl("//***************************************************************************")
46 cog.outl("// THIS FILE HAS BEEN AUTO GENERATED. DO NOT EDIT THIS FILE.")
47 cog.outl("//***************************************************************************")
48 ]]]*/
49 /*[[[end]]]*/
50 
51 //***************************************************************************
52 // To generate to header file, run this at the command line.
53 // Note: You will need Python and COG installed.
54 //
55 // python -m cogapp -d -e -otypes.h -DHandlers=<n> types_generator.h
56 // Where <n> is the number of types to support.
57 //
58 // e.g.
59 // To generate handlers for up to 16 types...
60 // python -m cogapp -d -e -otype_traits.h -DIsOneOf=16 type_traits_generator.h
61 //
62 // See generate.bat
63 //***************************************************************************
64 
65 #ifndef ETL_TYPE_TRAITS_INCLUDED
66 #define ETL_TYPE_TRAITS_INCLUDED
67 
68 #include <stddef.h>
69 #include <stdint.h>
70 
71 #include "platform.h"
72 #include "nullptr.h"
73 #include "static_assert.h"
74 
79 
80 #if ETL_USING_STL && ETL_CPP11_SUPPORTED
81  #include <type_traits>
82 #endif
83 
84 namespace etl
85 {
86 #if ETL_NOT_USING_STL || ETL_CPP11_NOT_SUPPORTED
87 
88  //*****************************************************************************
89  // Traits are defined by the ETL
90  //*****************************************************************************
91  //***************************************************************************
93  template <typename T, const T VALUE>
94  struct integral_constant
95  {
96  static const T value = VALUE;
97 
98  typedef T value_type;
99  typedef integral_constant<T, VALUE> type;
100 
101  operator value_type() const
102  {
103  return value;
104  }
105  };
106 
108  typedef integral_constant<bool, false> false_type;
109  typedef integral_constant<bool, true> true_type;
110 
111  template <typename T, const T VALUE>
112  const T integral_constant<T, VALUE>::value;
113 
114 #if ETL_CPP11_SUPPORTED
115  template <bool B>
116  using bool_constant = integral_constant<bool, B>;
117 #else
118  template <bool B>
119  struct bool_constant : etl::integral_constant<bool, B> { };
120 #endif
121 
122  //***************************************************************************
124  template <typename T>
125  struct negation : etl::bool_constant<!bool(T::value)>
126  {
127  };
128 
129 #if ETL_CPP17_SUPPORTED
130  template <typename T>
131  inline constexpr bool negation_v = negation<T>::value;
132 #endif
133 
134  //***************************************************************************
136  template <typename T> struct remove_reference { typedef T type; };
137  template <typename T> struct remove_reference<T&> { typedef T type; };
138 
139 #if ETL_CPP14_SUPPORTED
140  template <typename T>
141  using remove_reference_t = typename remove_reference<T>::type;
142 #endif
143 
144  //***************************************************************************
146  template <typename T> struct remove_pointer { typedef T type; };
147  template <typename T> struct remove_pointer<T*> { typedef T type; };
148  template <typename T> struct remove_pointer<const T*> { typedef const T type; };
149  template <typename T> struct remove_pointer<volatile T*> { typedef volatile T type; };
150  template <typename T> struct remove_pointer<const volatile T*> { typedef const volatile T type; };
151  template <typename T> struct remove_pointer<T* const> { typedef T type; };
152  template <typename T> struct remove_pointer<const T* const> { typedef const T type; };
153  template <typename T> struct remove_pointer<volatile T* const> { typedef volatile T type; };
154  template <typename T> struct remove_pointer<const volatile T* const> { typedef const volatile T type; };
155 
156 #if ETL_CPP14_SUPPORTED
157  template <typename T>
158  using remove_pointer_t = typename remove_pointer<T>::type;
159 #endif
160 
161  //***************************************************************************
163  template <typename T> struct add_pointer { typedef typename remove_reference<T>::type* type; };
164 
165 #if ETL_CPP14_SUPPORTED
166  template <typename T>
167  using add_pointer_t = typename add_pointer<T>::type;
168 #endif
169 
170  //***************************************************************************
172  template <typename T> struct is_const : false_type {};
173  template <typename T> struct is_const<const T> : true_type {};
174  template <typename T> struct is_const<const volatile T> : true_type {};
175 
176 #if ETL_CPP17_SUPPORTED
177  template <typename T>
178  inline constexpr bool is_const_v = is_const<T>::value;
179 #endif
180 
181  //***************************************************************************
183  template <typename T> struct remove_const { typedef T type; };
184  template <typename T> struct remove_const<const T> { typedef T type; };
185 
186 #if ETL_CPP14_SUPPORTED
187  template <typename T>
188  using remove_const_t = typename remove_const<T>::type;
189 #endif
190 
191  //***************************************************************************
193  template <typename T> struct add_const { typedef const T type; };
194  template <typename T> struct add_const<const T> { typedef const T type; };
195 
196 #if ETL_CPP14_SUPPORTED
197  template <typename T>
198  using add_const_t = typename add_const<T>::type;
199 #endif
200 
201  //***************************************************************************
203  template <typename T> struct is_volatile : false_type {};
204  template <typename T> struct is_volatile<volatile T> : true_type {};
205  template <typename T> struct is_volatile<const volatile T> : true_type {};
206 
207 #if ETL_CPP17_SUPPORTED
208  template <typename T>
209  inline constexpr bool is_volatile_v = is_volatile<T>::value;
210 #endif
211 
212  //***************************************************************************
214  template <typename T> struct remove_volatile { typedef T type; };
215  template <typename T> struct remove_volatile<volatile T> { typedef T type; };
216 
217 #if ETL_CPP14_SUPPORTED
218  template <typename T>
219  using remove_volatile_t = typename remove_volatile<T>::type;
220 #endif
221 
222  //***************************************************************************
224  template <typename T> struct add_volatile { typedef volatile T type; };
225  template <typename T> struct add_volatile<volatile T> { typedef volatile T type; };
226 
227 #if ETL_CPP14_SUPPORTED
228  template <typename T>
229  using add_volatile_t = typename add_volatile<T>::type;
230 #endif
231 
232  //***************************************************************************
234  template <typename T> struct remove_cv
235  {
236  typedef typename remove_volatile<typename remove_const<T>::type>::type type;
237  };
238 
239 #if ETL_CPP14_SUPPORTED
240  template <typename T>
241  using remove_cv_t = typename remove_cv<T>::type;
242 #endif
243 
244  //***************************************************************************
246  template <typename T> struct add_cv
247  {
248  typedef typename add_volatile<typename add_const<T>::type>::type type;
249  };
250 
251 #if ETL_CPP14_SUPPORTED
252  template <typename T>
253  using add_cv_t = typename add_cv<T>::type;
254 #endif
255 
256  //***************************************************************************
258  template <typename T> struct is_integral : false_type {};
259  template <> struct is_integral<bool> : true_type {};
260  template <> struct is_integral<char> : true_type {};
261  template <> struct is_integral<unsigned char> : true_type {};
262  template <> struct is_integral<signed char> : true_type {};
263  template <> struct is_integral<wchar_t> : true_type {};
264  template <> struct is_integral<short> : true_type {};
265  template <> struct is_integral<unsigned short> : true_type {};
266  template <> struct is_integral<int> : true_type {};
267  template <> struct is_integral<unsigned int> : true_type {};
268  template <> struct is_integral<long> : true_type {};
269  template <> struct is_integral<unsigned long> : true_type {};
270  template <> struct is_integral<long long> : true_type {};
271  template <> struct is_integral<unsigned long long> : true_type {};
272  template <typename T> struct is_integral<const T> : is_integral<T> {};
273  template <typename T> struct is_integral<volatile T> : is_integral<T> {};
274  template <typename T> struct is_integral<const volatile T> : is_integral<T> {};
275 
276 #if ETL_CPP17_SUPPORTED
277  template <typename T>
278  inline constexpr bool is_integral_v = is_integral<T>::value;
279 #endif
280 
281  //***************************************************************************
283  template <typename T> struct is_signed : false_type {};
284  template <> struct is_signed<char> : integral_constant<bool, (char(255) < 0)> {};
285  template <> struct is_signed<wchar_t> : public etl::integral_constant<bool, static_cast<bool>(wchar_t(-1) < wchar_t(0))> {};
286  template <> struct is_signed<signed char> : true_type {};
287  template <> struct is_signed<short> : true_type {};
288  template <> struct is_signed<int> : true_type {};
289  template <> struct is_signed<long> : true_type {};
290  template <> struct is_signed<long long> : true_type {};
291  template <> struct is_signed<float> : true_type {};
292  template <> struct is_signed<double> : true_type {};
293  template <> struct is_signed<long double> : true_type {};
294  template <typename T> struct is_signed<const T> : is_signed<T> {};
295  template <typename T> struct is_signed<volatile T> : is_signed<T> {};
296  template <typename T> struct is_signed<const volatile T> : is_signed<T> {};
297 
298 #if ETL_CPP17_SUPPORTED
299  template <typename T>
300  inline constexpr bool is_signed_v = is_signed<T>::value;
301 #endif
302 
303  //***************************************************************************
305  template <typename T> struct is_unsigned : false_type {};
306  template <> struct is_unsigned<bool> : true_type {};
307  template <> struct is_unsigned<char> : integral_constant<bool, (char(255) > 0)> {};
308  template <> struct is_unsigned<unsigned char> : true_type {};
309  template <> struct is_unsigned<wchar_t> : public etl::integral_constant<bool, (wchar_t(-1) > wchar_t(0))> {};
310  template <> struct is_unsigned<unsigned short> : true_type {};
311  template <> struct is_unsigned<unsigned int> : true_type {};
312  template <> struct is_unsigned<unsigned long> : true_type {};
313  template <> struct is_unsigned<unsigned long long> : true_type {};
314  template <typename T> struct is_unsigned<const T> : is_unsigned<T> {};
315  template <typename T> struct is_unsigned<volatile T> : is_unsigned<T> {};
316  template <typename T> struct is_unsigned<const volatile T> : is_unsigned<T> {};
317 
318 #if ETL_CPP17_SUPPORTED
319  template <typename T>
320  inline constexpr bool is_unsigned_v = is_unsigned<T>::value;
321 #endif
322 
323  //***************************************************************************
325  template <typename T> struct is_floating_point : false_type {};
326  template <> struct is_floating_point<float> : true_type {};
327  template <> struct is_floating_point<double> : true_type {};
328  template <> struct is_floating_point<long double> : true_type {};
329  template <typename T> struct is_floating_point<const T> : is_floating_point<T> {};
330  template <typename T> struct is_floating_point<volatile T> : is_floating_point<T> {};
331  template <typename T> struct is_floating_point<const volatile T> : is_floating_point<T> {};
332 
333 #if ETL_CPP17_SUPPORTED
334  template <typename T>
335  inline constexpr bool is_floating_point_v = is_floating_point<T>::value;
336 #endif
337 
338  //***************************************************************************
340  template <typename T1, typename T2> struct is_same : public false_type {};
341  template <typename T> struct is_same<T, T> : public true_type {};
342 
343 #if ETL_CPP17_SUPPORTED
344  template <typename T1, typename T2>
345  inline constexpr bool is_same_v = is_same<T1, T2>::value;
346 #endif
347 
348  //***************************************************************************
350  template<typename T> struct is_void : false_type {};
351  template<> struct is_void<void> : true_type {};
352 
353 #if ETL_CPP17_SUPPORTED
354  template <typename T>
355  inline constexpr bool is_void_v = is_void<T>::value;
356 #endif
357 
358  //***************************************************************************
360  template<typename T> struct is_arithmetic : integral_constant<bool, is_integral<T>::value || is_floating_point<T>::value> {};
361 
362 #if ETL_CPP17_SUPPORTED
363  template <typename T>
364  inline constexpr bool is_arithmetic_v = is_arithmetic<T>::value;
365 #endif
366 
367  //***************************************************************************
369  template <typename T> struct is_fundamental : integral_constant<bool, is_arithmetic<T>::value || is_void<T>::value> {};
370 
371 #if ETL_CPP17_SUPPORTED
372  template <typename T>
373  inline constexpr bool is_fundamental_v = is_fundamental<T>::value;
374 #endif
375 
376  //***************************************************************************
378  template <typename T> struct is_compound : integral_constant<bool, !is_fundamental<T>::value> {};
379 
380 #if ETL_CPP17_SUPPORTED
381  template <typename T>
382  inline constexpr bool is_compound_v = is_compound<T>::value;
383 #endif
384 
385  //***************************************************************************
387  template <typename T> struct is_array : false_type {};
388  template <typename T> struct is_array<T[]> : true_type {};
389  template <typename T, size_t MAXN> struct is_array<T[MAXN]> : true_type {};
390 
391 #if ETL_CPP17_SUPPORTED
392  template <typename T>
393  inline constexpr bool is_array_v = is_array<T>::value;
394 #endif
395 
396  //***************************************************************************
398  template<typename T> struct is_pointer_helper : false_type {};
399  template<typename T> struct is_pointer_helper<T*> : true_type {};
400  template<typename T> struct is_pointer : is_pointer_helper<typename remove_cv<T>::type> {};
401 
402 #if ETL_CPP17_SUPPORTED
403  template <typename T>
404  inline constexpr bool is_pointer_v = is_pointer<T>::value;
405 #endif
406 
407  //***************************************************************************
409  template<typename T> struct is_reference_helper : false_type {};
410  template<typename T> struct is_reference_helper<T&> : true_type {};
411  template<typename T> struct is_reference : is_reference_helper<typename remove_cv<T>::type> {};
412 
413 #if ETL_CPP17_SUPPORTED
414  template <typename T>
415  inline constexpr bool is_reference_v = is_reference<T>::value;
416 #endif
417 
418  //***************************************************************************
420  template<typename T> struct is_lvalue_reference_helper : false_type {};
421  template<typename T> struct is_lvalue_reference_helper<T&> : true_type {};
422  template<typename T> struct is_lvalue_reference : is_lvalue_reference_helper<typename remove_cv<T>::type> {};
423 
424 #if ETL_CPP17_SUPPORTED
425  template <typename T>
426  inline constexpr bool is_lvalue_reference_v = etl::is_lvalue_reference<T>::value;
427 #endif
428 
429 #if ETL_CPP11_SUPPORTED
430  //***************************************************************************
432  template<typename T> struct is_rvalue_reference_helper : false_type {};
433  template<typename T> struct is_rvalue_reference_helper<T&&> : true_type {};
434  template<typename T> struct is_rvalue_reference : is_rvalue_reference_helper<typename remove_cv<T>::type> {};
435 
436 #if ETL_CPP17_SUPPORTED
437  template <typename T>
438  inline constexpr bool is_rvalue_reference_v = etl::is_rvalue_reference<T>::value;
439 #endif
440 #endif
441 
442  //***************************************************************************
445  template <typename T> struct is_pod : etl::integral_constant<bool, etl::is_fundamental<T>::value || etl::is_pointer<T>::value> {};
446 
447 #if ETL_CPP17_SUPPORTED
448  template <typename T>
449  inline constexpr bool is_pod_v = etl::is_pod<T>::value;
450 #endif
451 
452  //***************************************************************************
455  template <typename T> struct is_trivially_constructible : etl::is_pod<T> {};
456 
457 #if ETL_CPP17_SUPPORTED
458  template <typename T>
459  inline constexpr bool is_trivially_constructible_v = etl::is_trivially_constructible<T>::value;
460 #endif
461 
462  //***************************************************************************
465  template <typename T> struct is_trivially_copy_constructible : etl::is_pod<T> {};
466 
467 #if ETL_CPP17_SUPPORTED
468  template <typename T>
469  inline constexpr bool is_trivially_copy_constructible_v = etl::is_trivially_copy_constructible<T>::value;
470 #endif
471 
472  //***************************************************************************
475  template <typename T> struct is_trivially_destructible : etl::is_pod<T> {};
476 
477 #if ETL_CPP17_SUPPORTED
478  template <typename T>
479  inline constexpr bool is_trivially_destructible_v = etl::is_trivially_destructible<T>::value;
480 #endif
481 
482  //***************************************************************************
485  template <typename T> struct is_trivially_copy_assignable : etl::is_pod<T> {};
486 
487 #if ETL_CPP17_SUPPORTED
488  template <typename T>
489  inline constexpr bool is_trivially_copy_assignable_v = etl::is_trivially_copy_assignable<T>::value;
490 #endif
491 
492  //***************************************************************************
495  template <typename T> struct is_trivially_copyable : etl::is_pod<T> {};
496 
497 #if ETL_CPP17_SUPPORTED
498  template <typename T>
499  inline constexpr bool is_trivially_copyable_v = etl::is_trivially_copyable<T>::value;
500 #endif
501 
502  //***************************************************************************
504  template <bool B, typename T, typename F> struct conditional { typedef T type; };
505  template <typename T, typename F> struct conditional<false, T, F> { typedef F type; };
506 
507  //***************************************************************************
509  template <typename T> struct make_signed { typedef T type; };
510  template <> struct make_signed<char> { typedef signed char type; };
511  template <> struct make_signed<unsigned char> { typedef signed char type; };
512 
513  template <> struct make_signed<wchar_t>
514  {
515  typedef etl::conditional<sizeof(wchar_t) == sizeof(int16_t),
516  int16_t,
517  etl::conditional<sizeof(wchar_t) == sizeof(int32_t),
518  int32_t,
519  void>::type>::type type;
520  };
521 
522  template <> struct make_signed<unsigned short> { typedef short type; };
523  template <> struct make_signed<unsigned int> { typedef int type; };
524  template <> struct make_signed<unsigned long> { typedef long type; };
525  template <> struct make_signed<unsigned long long> { typedef long long type; };
526  template <typename T> struct make_signed<const T> : add_const<typename make_signed<T>::type> {};
527  template <typename T> struct make_signed<volatile T> : add_volatile<typename make_signed<T>::type> {};
528  template <typename T> struct make_signed<const volatile T> : add_const<typename add_volatile<typename make_signed<T>::type>::type> {};
529 
530 #if ETL_CPP14_SUPPORTED
531  template <typename T>
532  using make_signed_t = typename make_signed<T>::type;
533 #endif
534 
535  //***************************************************************************
537  template <typename T> struct make_unsigned { typedef T type; };
538  template <> struct make_unsigned<char> { typedef unsigned char type; };
539  template <> struct make_unsigned<signed char> { typedef unsigned char type; };
540  template <> struct make_unsigned<short> { typedef unsigned short type; };
541 
542  template <> struct make_unsigned<wchar_t>
543  {
544  typedef etl::conditional<sizeof(wchar_t) == sizeof(uint16_t),
545  uint16_t,
546  etl::conditional<sizeof(wchar_t) == sizeof(uint32_t),
547  uint32_t,
548  void>::type>::type type;
549  };
550 
551  template <> struct make_unsigned<int> { typedef unsigned int type; };
552  template <> struct make_unsigned<long> { typedef unsigned long type; };
553  template <> struct make_unsigned<long long> { typedef unsigned long long type; };
554  template <typename T> struct make_unsigned<const T> : add_const<typename make_unsigned<T>::type> {};
555  template <typename T> struct make_unsigned<volatile T> : add_volatile<typename make_unsigned<T>::type> {};
556  template <typename T> struct make_unsigned<const volatile T> : add_const<typename add_volatile<typename make_unsigned<T>::type>::type> {};
557 
558 #if ETL_CPP14_SUPPORTED
559  template <typename T>
560  using make_unsigned_t = typename make_unsigned<T>::type;
561 #endif
562 
563  //***************************************************************************
565  template <bool B, typename T = void> struct enable_if {};
566  template <typename T> struct enable_if<true, T> { typedef T type; };
567 
568 #if ETL_CPP14_SUPPORTED
569  template <bool B, typename T = void>
570  using enable_if_t = typename enable_if<B, T>::type;
571 #endif
572 
573  //***************************************************************************
575  template <typename T, size_t MAXN = 0U>
576  struct extent : integral_constant<size_t, 0U> {};
577 
578  template <typename T>
579  struct extent<T[], 0> : integral_constant<size_t, 0U> {};
580 
581  template <typename T, size_t MAXN>
582  struct extent<T[], MAXN> : integral_constant<size_t, extent<T, MAXN - 1>::value> {};
583 
584  template <typename T, size_t MAXN>
585  struct extent<T[MAXN], 0> : integral_constant<size_t, MAXN> {};
586 
587  template <typename T, size_t I, size_t MAXN>
588  struct extent<T[I], MAXN> : integral_constant<size_t, extent<T, MAXN - 1>::value> {};
589 
590 #if ETL_CPP17_SUPPORTED
591  template <typename T, size_t N = 0U>
592  inline constexpr size_t extent_v = extent<T, N>::value;
593 #endif
594 
595  //***************************************************************************
597  template <typename T> struct remove_extent { typedef T type; };
598  template <typename T> struct remove_extent<T[]> { typedef T type; };
599  template <typename T, size_t MAXN> struct remove_extent<T[MAXN]> { typedef T type; };
600 
601 #if ETL_CPP14_SUPPORTED
602  template <typename T>
603  using remove_extent_t = typename remove_extent<T>::type;
604 #endif
605 
606  //***************************************************************************
608  template <typename T> struct remove_all_extents { typedef T type; };
609  template <typename T> struct remove_all_extents<T[]> { typedef typename remove_all_extents<T>::type type; };
610  template <typename T, size_t MAXN> struct remove_all_extents<T[MAXN]> { typedef typename remove_all_extents<T>::type type; };
611 
612 #if ETL_CPP14_SUPPORTED
613  template <typename T>
614  using remove_all_extents_t = typename remove_all_extents<T>::type;
615 #endif
616 
617  //***************************************************************************
619  template <typename T>struct rank : integral_constant<size_t, 0> {};
620  template <typename T> struct rank<T[]> : public integral_constant<size_t, rank<T>::value + 1> {};
621  template <typename T, size_t MAXN> struct rank<T[MAXN]> : public integral_constant<size_t, rank<T>::value + 1> {};
622 
623 #if ETL_CPP17_SUPPORTED
624  template <typename T>
625  inline constexpr size_t rank_v = rank<T>::value;
626 #endif
627 
628  //***************************************************************************
630  template <typename T>
631  struct decay
632  {
633  typedef typename etl::remove_reference<T>::type U;
635  typename etl::remove_extent<U>::type*,
636  typename etl::remove_cv<U>::type>::type type;
637  };
638 
639 #if ETL_CPP14_SUPPORTED
640  template <typename T>
641  using decay_t = typename decay<T>::type;
642 #endif
643 
644  //***************************************************************************
646  template<typename TBase,
647  typename TDerived,
649  struct is_base_of
650  {
651  private:
652 
653  template<typename T> struct dummy {};
654  struct internal: TDerived, dummy<int>{};
655 
656  static TBase* check(TBase*);
657  template<typename T> static char check(dummy<T>*);
658 
659  public:
660 
661  static const bool value = (sizeof(check((internal*)0)) == sizeof(TBase*));
662  };
663 
664  // For when TBase or TDerived is a fundamental type.
665  template<typename TBase, typename TDerived>
666  struct is_base_of<TBase, TDerived, true>
667  {
668  static const bool value = false;
669  };
670 
671 #if ETL_CPP17_SUPPORTED
672  template <typename T1, typename T2>
673  inline constexpr bool is_base_of_v = is_base_of<T1, T2>::value;
674 #endif
675 
676  //***************************************************************************
678  namespace private_type_traits
679  {
680  template <typename T> char test(int T::*); // Match for classes.
681 
682  struct dummy { char c[2]; };
683  template <typename T> dummy test(...); // Match for non-classes.
684  }
685 
686  template <typename T>
688 
689 #if ETL_CPP17_SUPPORTED
690  template <typename T>
691  inline constexpr bool is_class_v = is_class<T>::value;
692 #endif
693 
694  //***************************************************************************
696  template <typename T> struct add_lvalue_reference { typedef T& type; };
697  template <typename T> struct add_lvalue_reference<T&> { typedef T& type; };
698  template <> struct add_lvalue_reference<void> { typedef void type; };
699  template <> struct add_lvalue_reference<const void> { typedef const void type; };
700  template <> struct add_lvalue_reference<volatile void> { typedef volatile void type; };
701  template <> struct add_lvalue_reference<const volatile void> { typedef const volatile void type; };
702 
703 #if ETL_CPP14_SUPPORTED
704  template <typename T>
705  using add_lvalue_reference_t = typename etl::add_lvalue_reference<T>::type;
706 #endif
707 
708  //***************************************************************************
710 #if ETL_CPP11_SUPPORTED
711  template <typename T> struct add_rvalue_reference { using type = T && ; };
712  template <typename T> struct add_rvalue_reference<T&> { using type = T & ; };
713  template <> struct add_rvalue_reference<void> { using type = void; };
714  template <> struct add_rvalue_reference<const void> { using type = const void; };
715  template <> struct add_rvalue_reference<volatile void> { using type = volatile void; };
716  template <> struct add_rvalue_reference<const volatile void> { using type = const volatile void; };
717 #endif
718 
719 #if ETL_CPP14_SUPPORTED
720  template <typename T>
721  using add_rvalue_reference_t = typename etl::add_rvalue_reference<T>::type;
722 #endif
723 
724  //***************************************************************************
726 #if ETL_CPP11_SUPPORTED
727  template <typename T>
728  typename etl::add_rvalue_reference<T>::type declval() ETL_NOEXCEPT;
729 #endif
730 
731  //***************************************************************************
733 #if ETL_CPP11_SUPPORTED
734  namespace private_type_traits
735  {
736  template <typename>
737  using true_type_for = etl::true_type;
738 
739  template <typename T>
740  auto returnable(int)->true_type_for<T()>;
741 
742  template <typename>
743  auto returnable(...)->etl::false_type;
744 
745  template <typename TFrom, typename TTo>
746  auto nonvoid_convertible(int)->true_type_for<decltype(etl::declval<void(&)(TTo)>()(etl::declval<TFrom>()))
747  >;
748  template <typename, typename>
749  auto nonvoid_convertible(...)->etl::false_type;
750  }
751 
752 #if defined(ETL_COMPILER_ARM5)
753  template <typename TFrom, typename TTo>
754  struct is_convertible : etl::integral_constant<bool, __is_convertible_to(TFrom, TTo)> {};
755 #else
756  template <typename TFrom, typename TTo>
757  struct is_convertible : etl::integral_constant<bool, (decltype(private_type_traits::returnable<TTo>(0))::value &&
758  decltype(private_type_traits::nonvoid_convertible<TFrom, TTo>(0))::value) ||
759  (etl::is_void<TFrom>::value && etl::is_void<TTo>::value)> {};
760 #endif
761 #endif
762 
763 #if ETL_CPP17_SUPPORTED
764  template <typename TFrom, typename TTo >
765  inline constexpr bool is_convertible_v = etl::is_convertible<TFrom, TTo>::value;
766 #endif
767 
768  //***************************************************************************
771 #if ETL_CPP11_SUPPORTED && !defined(ETL_COMPILER_ARM5)
772  template <typename T> struct alignment_of : integral_constant<size_t, alignof(T)> { };
773 #elif defined(ETL_COMPILER_MICROSOFT)
774  template <typename T> struct alignment_of : integral_constant<size_t, size_t(__alignof(T))> {};
775 #elif defined(ETL_COMPILER_IAR) || defined(ETL_COMPILER_TI)
776  template <typename T> struct alignment_of : integral_constant<size_t, size_t(__ALIGNOF__(T))> {};
777 #else
778  template <typename T> struct alignment_of : integral_constant<size_t, size_t(__alignof__(T))> {};
779 #endif
780 
783  template <> struct alignment_of<void> : integral_constant <size_t, 0> {};
784 
785 #if ETL_CPP17_SUPPORTED
786  template <typename T>
787  inline constexpr size_t alignment_of_v = etl::alignment_of<T>::value;
788 #endif
789 
790 #else // Condition = ETL_USING_STL && ETL_CPP11_SUPPORTED
791 
792  //*****************************************************************************
793  // Traits are derived from the STL
794  //*****************************************************************************
795 
796  //***************************************************************************
799  template <typename T, const T VALUE>
800  struct integral_constant : std::integral_constant<T, VALUE> {};
801 
806 
807 #if ETL_CPP17_SUPPORTED
808  template <bool B>
809  using bool_constant = std::bool_constant<B>;
810 #else
811  template <bool B>
812  struct bool_constant : std::integral_constant<bool, B> { };
813 #endif
814 
815  //***************************************************************************
818 #if ETL_CPP17_SUPPORTED
819  template <typename T>
820  struct negation : std::negation<T>
821  {
822  };
823 
824  template <typename T>
825  inline constexpr bool negation_v = std::negation_v<T>;
826 #endif
827 
828  //***************************************************************************
831  template <typename T> struct remove_reference : std::remove_reference<T> {};
832 
833 #if ETL_CPP14_SUPPORTED
834  template <typename T>
835  using remove_reference_t = std::remove_reference_t<T>;
836 #endif
837 
838  //***************************************************************************
841  template <typename T> struct remove_pointer : std::remove_pointer<T> {};
842 
843 #if ETL_CPP14_SUPPORTED
844  template <typename T>
845  using remove_pointer_t = std::remove_pointer_t<T>;
846 #endif
847 
848  //***************************************************************************
851  template <typename T> struct add_pointer : std::add_pointer<T> {};
852 
853 #if ETL_CPP14_SUPPORTED
854  template <typename T>
855  using add_pointer_t = std::add_pointer_t<T>;
856 #endif
857 
858  //***************************************************************************
861  template <typename T> struct is_const : std::is_const<T> {};
862 
863 #if ETL_CPP17_SUPPORTED
864  template <typename T>
865  inline constexpr bool is_const_v = std::is_const_v<T>;
866 #endif
867 
868  //***************************************************************************
871  template <typename T> struct remove_const : std::remove_const<T> {};
872 
873 #if ETL_CPP14_SUPPORTED
874  template <typename T>
875  using remove_const_t = std::remove_const_t<T>;
876 #endif
877 
878  //***************************************************************************
881  template <typename T> struct add_const : std::add_const<T> {};
882 
883 #if ETL_CPP14_SUPPORTED
884  template <typename T>
885  using add_const_t = std::add_const_t<T>;
886 #endif
887 
888  //***************************************************************************
891  template <typename T> struct is_volatile : std::is_volatile<T> {};
892 
893 #if ETL_CPP17_SUPPORTED
894  template <typename T>
895  inline constexpr bool is_volatile_v = std::is_volatile_v<T>;
896 #endif
897 
898  //***************************************************************************
901  template <typename T> struct remove_volatile : std::remove_volatile<T> {};
902 
903 #if ETL_CPP14_SUPPORTED
904  template <typename T>
905  using remove_volatile_t = std::remove_volatile_t<T>;
906 #endif
907 
908  //***************************************************************************
911  template <typename T> struct add_volatile : std::add_volatile<T> {};
912 
913 #if ETL_CPP14_SUPPORTED
914  template <typename T>
915  using add_volatile_t = std::add_volatile_t<T>;
916 #endif
917 
918  //***************************************************************************
921  template <typename T> struct remove_cv : std::remove_cv<T> {};
922 
923 #if ETL_CPP14_SUPPORTED
924  template <typename T>
925  using remove_cv_t = std::remove_cv_t<T>;
926 #endif
927 
928  //***************************************************************************
931  template <typename T> struct add_cv : std::add_cv<T> {};
932 
933 #if ETL_CPP14_SUPPORTED
934  template <typename T>
935  using add_cv_t = std::add_cv_t<T>;
936 #endif
937 
938  //***************************************************************************
941  template <typename T> struct is_integral : std::is_integral<T> {};
942 
943 #if ETL_CPP17_SUPPORTED
944  template <typename T>
945  inline constexpr bool is_integral_v = std::is_integral_v<T>;
946 #endif
947 
948  //***************************************************************************
951  template <typename T> struct is_signed : std::is_signed<T> {};
952 
953 #if ETL_CPP17_SUPPORTED
954  template <typename T>
955  inline constexpr bool is_signed_v = std::is_signed_v<T>;
956 #endif
957 
958  //***************************************************************************
961  template <typename T> struct is_unsigned : std::is_unsigned<T> {};
962 
963 #if ETL_CPP17_SUPPORTED
964  template <typename T>
965  inline constexpr bool is_unsigned_v = std::is_unsigned_v<T>;
966 #endif
967 
968  //***************************************************************************
971  template <typename T> struct is_floating_point : std::is_floating_point<T> {};
972 
973 #if ETL_CPP17_SUPPORTED
974  template <typename T>
975  inline constexpr bool is_floating_point_v = std::is_floating_point_v<T>;
976 #endif
977 
978  //***************************************************************************
981  template <typename T1, typename T2> struct is_same : std::is_same<T1, T2> {};
982 
983 #if ETL_CPP17_SUPPORTED
984  template <typename T1, typename T2>
985  inline constexpr bool is_same_v = std::is_same_v<T1, T2>;
986 #endif
987 
988  //***************************************************************************
991  template<typename T> struct is_void : std::is_void<T> {};
992 
993 #if ETL_CPP17_SUPPORTED
994  template <typename T>
995  inline constexpr bool is_void_v = std::is_void_v<T>;
996 #endif
997 
998  //***************************************************************************
1001  template<typename T> struct is_arithmetic : std::is_arithmetic<T> {};
1002 
1003 #if ETL_CPP17_SUPPORTED
1004  template <typename T>
1005  inline constexpr bool is_arithmetic_v = std::is_arithmetic_v<T>;
1006 #endif
1007 
1008  //***************************************************************************
1011  template <typename T> struct is_fundamental : std::is_fundamental<T> {};
1012 
1013 #if ETL_CPP17_SUPPORTED
1014  template <typename T>
1015  inline constexpr bool is_fundamental_v = std::is_fundamental_v<T>;
1016 #endif
1017 
1018  //***************************************************************************
1021  template <typename T> struct is_compound : std::is_compound<T> {};
1022 
1023 #if ETL_CPP17_SUPPORTED
1024  template <typename T>
1025  inline constexpr bool is_compound_v = std::is_compound_v<T>;
1026 #endif
1027 
1028  //***************************************************************************
1031  template <typename T> struct is_array : std::is_array<T> {};
1032 
1033 #if ETL_CPP17_SUPPORTED
1034  template <typename T>
1035  inline constexpr bool is_array_v = std::is_array_v<T>;
1036 #endif
1037 
1038  //***************************************************************************
1041  template<typename T> struct is_pointer : std::is_pointer<T> {};
1042 
1043 #if ETL_CPP17_SUPPORTED
1044  template <typename T>
1045  inline constexpr bool is_pointer_v = std::is_pointer_v<T>;
1046 #endif
1047 
1048  //***************************************************************************
1051  template<typename T> struct is_reference : std::is_reference<T> {};
1052 
1053 #if ETL_CPP17_SUPPORTED
1054  template <typename T>
1055  inline constexpr bool is_reference_v = std::is_reference_v<T>;
1056 #endif
1057 
1058  //***************************************************************************
1061  template<typename T> struct is_lvalue_reference : std::is_lvalue_reference<T> {};
1062 
1063 #if ETL_CPP17_SUPPORTED
1064  template <typename T>
1065  inline constexpr bool is_lvalue_reference_v = std::is_lvalue_reference_v<T>;
1066 #endif
1067 
1068  //***************************************************************************
1071 #if ETL_CPP11_SUPPORTED
1072  template<typename T> struct is_rvalue_reference : std::is_rvalue_reference<T> {};
1073 
1074 #if ETL_CPP17_SUPPORTED
1075  template <typename T>
1076  inline constexpr bool is_rvalue_reference_v = std::is_rvalue_reference_v<T>;
1077 #endif
1078 #endif
1079 
1080  //***************************************************************************
1083  template <typename T>
1084  struct is_pod : std::integral_constant<bool, std::is_standard_layout<T>::value && std::is_trivial<T>::value> {};
1085 
1086 #if ETL_CPP17_SUPPORTED
1087  template <typename T>
1088  inline constexpr bool is_pod_v = std::is_standard_layout_v<T> && std::is_trivial_v<T>;
1089 #endif
1090 
1091 #if defined(ETL_COMPILER_GCC)
1092  #if ETL_COMPILER_VERSION >= 5
1093  #define ETL_GCC_V5_TYPE_TRAITS_SUPPORTED
1094  #endif
1095 #endif
1096 
1097 #if !defined(ARDUINO) && ETL_NOT_USING_STLPORT && defined(ETL_GCC_V5_TYPE_TRAITS_SUPPORTED)
1098  //***************************************************************************
1101  template <typename T> struct is_trivially_constructible : std::is_trivially_constructible<T> {};
1102 
1103 #if ETL_CPP17_SUPPORTED
1104  template <typename T>
1105  inline constexpr bool is_trivially_constructible_v = std::is_trivially_constructible_v<T>;
1106 #endif
1107 
1108  //***************************************************************************
1111  template <typename T> struct is_trivially_copy_constructible : std::is_trivially_copy_constructible<T> {};
1112 
1113 #if ETL_CPP17_SUPPORTED
1114  template <typename T>
1115  inline constexpr bool is_trivially_copy_constructible_v = std::is_trivially_copy_constructible_v<T>;
1116 #endif
1117 
1118  //***************************************************************************
1121  template <typename T> struct is_trivially_destructible : std::is_trivially_destructible<T> {};
1122 
1123 #if ETL_CPP17_SUPPORTED
1124  template <typename T>
1125  inline constexpr bool is_trivially_destructible_v = std::is_trivially_destructible_v<T>;
1126 #endif
1127 
1128  //***************************************************************************
1131  template <typename T> struct is_trivially_copy_assignable : std::is_trivially_copy_assignable<T> {};
1132 
1133 #if ETL_CPP17_SUPPORTED
1134  template <typename T>
1135  inline constexpr bool is_trivially_copy_assignable_v = std::is_trivially_copy_assignable_v<T>;
1136 #endif
1137 
1138  //***************************************************************************
1141  template <typename T> struct is_trivially_copyable : std::is_trivially_copyable<T> {};
1142 
1143 #if ETL_CPP17_SUPPORTED
1144  template <typename T>
1145  inline constexpr bool is_trivially_copyable_v = std::is_trivially_copyable_v<T>;
1146 #endif
1147 #else
1148  //***************************************************************************
1151  template <typename T> struct is_trivially_constructible : std::is_pod<T> {};
1152 
1153  #if ETL_CPP17_SUPPORTED
1154  template <typename T>
1155  inline constexpr bool is_trivially_constructible_v = std::is_pod_v<T>;
1156  #endif
1157 
1158  //***************************************************************************
1161  template <typename T> struct is_trivially_copy_constructible : std::is_pod<T> {};
1162 
1163  #if ETL_CPP17_SUPPORTED
1164  template <typename T>
1165  inline constexpr bool is_trivially_copy_constructible_v = std::is_pod_v<T>;
1166  #endif
1167 
1168  //***************************************************************************
1171  template <typename T> struct is_trivially_destructible : std::is_pod<T> {};
1172 
1173  #if ETL_CPP17_SUPPORTED
1174  template <typename T>
1175  inline constexpr bool is_trivially_destructible_v = std::is_pod_v<T>;
1176  #endif
1177 
1178  //***************************************************************************
1181  template <typename T> struct is_trivially_copy_assignable : std::is_pod<T> {};
1182 
1183  #if ETL_CPP17_SUPPORTED
1184  template <typename T>
1185  inline constexpr bool is_trivially_copy_assignable_v = std::is_pod_v<T>;
1186  #endif
1187 
1188  //***************************************************************************
1191  template <typename T> struct is_trivially_copyable : std::is_pod<T> {};
1192 
1193  #if ETL_CPP17_SUPPORTED
1194  template <typename T>
1195  inline constexpr bool is_trivially_copyable_v = std::is_pod_v<T>;
1196  #endif
1197 #endif
1198 
1199  //***************************************************************************
1202  template <bool B, typename T, typename F> struct conditional { typedef T type; };
1203  template <typename T, typename F> struct conditional<false, T, F> { typedef F type; };
1204 
1205  //***************************************************************************
1208  template <typename T> struct make_signed : std::make_signed<T> {};
1209 
1210 #if ETL_CPP14_SUPPORTED
1211  template <typename T>
1212  using make_signed_t = std::make_signed_t<T>;
1213 #endif
1214 
1215  //***************************************************************************
1218  template <typename T> struct make_unsigned : std::make_unsigned<T> {};
1219 
1220 #if ETL_CPP14_SUPPORTED
1221  template <typename T>
1222  using make_unsigned_t = std::make_unsigned_t<T>;
1223 #endif
1224 
1225  //***************************************************************************
1228  template <bool B, typename T = void> struct enable_if : std::enable_if<B, T> {};
1229 
1230 #if ETL_CPP14_SUPPORTED
1231  template <bool B, typename T = void>
1232  using enable_if_t = std::enable_if_t<B, T>;
1233 #endif
1234 
1235  //***************************************************************************
1238  template <typename T, size_t MAXN = 0U>
1239  struct extent : std::extent<T, MAXN> {};
1240 
1241 #if ETL_CPP17_SUPPORTED
1242  template <typename T, size_t MAXN = 0U>
1243  inline constexpr size_t extent_v = std::extent_v<T, MAXN>;
1244 #endif
1245 
1246  //***************************************************************************
1249  template <typename T> struct remove_extent : std::remove_extent<T> { };
1250 
1251 #if ETL_CPP14_SUPPORTED
1252  template <typename T>
1253  using remove_extent_t = std::remove_extent_t<T>;
1254 #endif
1255 
1256  //***************************************************************************
1259  template <typename T> struct remove_all_extents : std::remove_all_extents<T> { };
1260 
1261 #if ETL_CPP14_SUPPORTED
1262  template <typename T>
1263  using remove_all_extents_t = std::remove_all_extents_t<T>;
1264 #endif
1265 
1266  //***************************************************************************
1269  template <typename T>struct rank : std::rank<T> {};
1270 
1271 #if ETL_CPP17_SUPPORTED
1272  template <typename T>
1273  inline constexpr size_t rank_v = std::rank_v<T>;
1274 #endif
1275 
1276  //***************************************************************************
1279  template <typename T> struct decay : std::decay<T> {};
1280 
1281 #if ETL_CPP14_SUPPORTED
1282  template <typename T>
1283  using decay_t = std::decay_t<T>;
1284 #endif
1285 
1286  //***************************************************************************
1289  template<typename TBase, typename TDerived> struct is_base_of : std::is_base_of<TBase, TDerived> {};
1290 
1291 #if ETL_CPP17_SUPPORTED
1292  template <typename TBase, typename TDerived>
1293  inline constexpr bool is_base_of_v = std::is_base_of_v<TBase, TDerived>;
1294 #endif
1295 
1296  //***************************************************************************
1298  template <typename T> struct is_class : std::is_class<T>{};
1299 
1300 #if ETL_CPP17_SUPPORTED
1301  template <typename T>
1302  inline constexpr bool is_class_v = is_class<T>::value;
1303 #endif
1304 
1305  //***************************************************************************
1307  template <typename T> struct add_lvalue_reference : std::add_lvalue_reference<T> {};
1308 
1309 #if ETL_CPP14_SUPPORTED
1310  template <typename T>
1311  using add_lvalue_reference_t = std::add_lvalue_reference_t<T>;
1312 #endif
1313 
1314  //***************************************************************************
1316 #if ETL_CPP11_SUPPORTED
1317  template <typename T> struct add_rvalue_reference : std::add_rvalue_reference<T> {};
1318 #endif
1319 
1320 #if ETL_CPP14_SUPPORTED
1321  template <typename T>
1322  using add_rvalue_reference_t = std::add_rvalue_reference_t<T>;
1323 #endif
1324 
1325  //***************************************************************************
1327 #if ETL_CPP11_SUPPORTED
1328  template <typename T>
1329  typename std::add_rvalue_reference<T>::type declval() ETL_NOEXCEPT;
1330 #endif
1331 
1332  //***************************************************************************
1335 #if ETL_CPP11_SUPPORTED
1336  template <typename TFrom, typename TTo>
1337  struct is_convertible : std::is_convertible<TFrom, TTo> {};
1338 #endif
1339 
1340 #if ETL_CPP17_SUPPORTED
1341  template <typename TFrom, typename TTo>
1342  inline constexpr bool is_convertible_v = std::is_convertible_v<TFrom, TTo>;
1343 #endif
1344 
1345  //***************************************************************************
1348  template <typename T> struct alignment_of : std::alignment_of<T> {};
1349  template <> struct alignment_of<void> : std::integral_constant<size_t, 0> {};
1350 
1351 #if ETL_CPP17_SUPPORTED
1352  template <typename T>
1353  inline constexpr size_t alignment_of_v = std::alignment_of_v<T>;
1354 #endif
1355 
1356 #endif // Condition = ETL_USING_STL && ETL_CPP11_SUPPORTED
1357 
1358  //***************************************************************************
1359  // ETL extended type traits.
1360  //***************************************************************************
1361 
1362  //***************************************************************************
1364  // /\ingroup type_traits
1365  template <bool B, typename T, T TRUE_VALUE, T FALSE_VALUE>
1367 
1368  template <typename T, T TRUE_VALUE, T FALSE_VALUE>
1369  struct conditional_integral_constant<true, T, TRUE_VALUE, FALSE_VALUE>
1370  {
1371  ETL_STATIC_ASSERT(etl::is_integral<T>::value, "Not an integral type");
1372  static const T value = TRUE_VALUE;
1373  };
1374 
1375  template <typename T, T TRUE_VALUE, T FALSE_VALUE>
1376  struct conditional_integral_constant<false, T, TRUE_VALUE, FALSE_VALUE>
1377  {
1378  ETL_STATIC_ASSERT(etl::is_integral<T>::value, "Not an integral type");
1379  static const T value = FALSE_VALUE;
1380  };
1381 
1382 
1383 #if ETL_CPP11_SUPPORTED
1384  //***************************************************************************
1387  template <typename T, typename T1, typename... TRest>
1388  struct is_one_of
1389  {
1390  static const bool value = etl::is_same<T, T1>::value ||
1391  etl::is_one_of<T, TRest...>::value;
1392  };
1393 
1394  template <typename T, typename T1>
1395  struct is_one_of<T, T1>
1396  {
1397  static const bool value = etl::is_same<T, T1>::value;
1398  };
1399 #else
1400  /*[[[cog
1401  import cog
1402  cog.outl("//***************************************************************************")
1403  cog.outl("/// Template to determine if a type is one of a specified list.")
1404  cog.outl("///\ingroup types")
1405  cog.outl("template <typename T,")
1406  cog.out(" ")
1407  cog.out("typename T1, ")
1408  for n in range(2, int(IsOneOf)):
1409  cog.out("typename T%s = void, " % n)
1410  if n % 4 == 0:
1411  cog.outl("")
1412  cog.out(" ")
1413  cog.outl("typename T%s = void>" % IsOneOf)
1414  cog.outl("struct is_one_of")
1415  cog.outl("{")
1416  cog.outl(" static const bool value = ")
1417  for n in range(1, int(IsOneOf)):
1418  cog.outl(" etl::is_same<T, T%s>::value ||" % n)
1419  cog.outl(" etl::is_same<T, T%s>::value;" % IsOneOf)
1420  cog.outl("};")
1421  ]]]*/
1422  /*[[[end]]]*/
1423 #endif
1424 
1425 #if ETL_CPP17_SUPPORTED
1426  template <typename T, typename... TRest>
1427  inline constexpr bool is_one_of_v = etl::is_one_of<T, TRest...>::value;
1428 #endif
1429 
1430  //***************************************************************************
1433 
1434  // Default.
1435  template <typename T>
1436  struct types
1437  {
1438  private:
1439 
1440  typedef typename etl::remove_reference<typename etl::remove_cv<T>::type>::type type_t;
1441 
1442  public:
1443 
1444  typedef type_t type;
1445  typedef type_t& reference;
1446  typedef const type_t& const_reference;
1447  typedef type_t* pointer;
1448  typedef const type_t* const_pointer;
1449  typedef const type_t* const const_pointer_const;
1450 
1451 #if ETL_CPP11_SUPPORTED
1452  typedef type_t&& rvalue_reference;
1453 #endif
1454  };
1455 
1456  // Pointers.
1457  template <typename T>
1458  struct types<T*>
1459  {
1460  private:
1461 
1462  typedef typename etl::remove_reference<typename etl::remove_cv<T>::type>::type type_t;
1463 
1464  public:
1465 
1466  typedef type_t type;
1467  typedef type_t& reference;
1468  typedef const type_t& const_reference;
1469  typedef type_t* pointer;
1470  typedef const type_t* const_pointer;
1471  typedef const type_t* const const_pointer_const;
1472 
1473 #if ETL_CPP11_SUPPORTED
1474  typedef type_t&& rvalue_reference;
1475 #endif
1476  };
1477 
1478  // Pointers.
1479  template <typename T>
1480  struct types<T* const>
1481  {
1482  private:
1483 
1484  typedef typename etl::remove_reference<typename etl::remove_cv<T>::type>::type type_t;
1485 
1486  public:
1487 
1488  typedef type_t type;
1489  typedef type_t& reference;
1490  typedef const type_t& const_reference;
1491  typedef type_t* pointer;
1492  typedef const type_t* const_pointer;
1493  typedef const type_t* const const_pointer_const;
1494 
1495 #if ETL_CPP11_SUPPORTED
1496  typedef type_t&& rvalue_reference;
1497 #endif
1498  };
1499 
1500  // References.
1501  template <typename T>
1502  struct types<T&>
1503  {
1504  private:
1505 
1506  typedef typename etl::remove_reference<typename etl::remove_cv<T>::type>::type type_t;
1507 
1508  public:
1509 
1510  typedef type_t type;
1511  typedef type_t& reference;
1512  typedef const type_t& const_reference;
1513  typedef type_t* pointer;
1514  typedef const type_t* const_pointer;
1515  typedef const type_t* const const_pointer_const;
1516 
1517 #if ETL_CPP11_SUPPORTED
1518  typedef type_t&& rvalue_reference;
1519 #endif
1520  };
1521 
1522 #if ETL_CPP11_SUPPORTED
1523  // rvalue References.
1524  template <typename T>
1525  struct types<T&&>
1526  {
1527  private:
1528 
1529  typedef typename etl::remove_reference<typename etl::remove_cv<T>::type>::type type_t;
1530 
1531  public:
1532 
1533  typedef type_t type;
1534  typedef type_t& reference;
1535  typedef const type_t& const_reference;
1536  typedef type_t* pointer;
1537  typedef const type_t* const_pointer;
1538  typedef const type_t* const const_pointer_const;
1539 
1540 #if ETL_CPP11_SUPPORTED
1541  typedef type_t&& rvalue_reference;
1542 #endif
1543  };
1544 #endif
1545 
1546 #if ETL_CPP11_SUPPORTED
1547  template <typename T>
1548  using types_t = typename types<T>::type;
1549 
1550  template <typename T>
1551  using types_r = typename types<T>::reference;
1552 
1553  template <typename T>
1554  using types_cr = typename types<T>::const_reference;
1555 
1556  template <typename T>
1557  using types_rr = typename types<T>::rvalue_reference;
1558 
1559  template <typename T>
1560  using types_p = typename types<T>::pointer;
1561 
1562  template <typename T>
1563  using types_cp = typename types<T>::const_pointer;
1564 
1565  template <typename T>
1566  using types_cpc = typename types<T>::const_pointer_const;
1567 #endif
1568 
1569  //***************************************************************************
1572  template <typename T> struct size_of : etl::integral_constant<size_t, sizeof(T)> {};
1573  template <> struct size_of<void> : etl::integral_constant<size_t, 1U> {};
1574 
1575 #if ETL_CPP17_SUPPORTED
1576  template <typename T>
1577  inline constexpr size_t size_of_v = etl::size_of<T>::value;
1578 #endif
1579 
1580 #if ETL_CPP11_SUPPORTED
1581  //***************************************************************************
1583  template <typename T, typename T1, typename... TRest>
1584  struct are_all_same
1585  {
1586  static const bool value = etl::is_same<T, T1>::value &&
1587  etl::are_all_same<T, TRest...>::value;
1588  };
1589 
1590  template <typename T, typename T1>
1591  struct are_all_same<T, T1>
1592  {
1593  static const bool value = etl::is_same<T, T1>::value;
1594  };
1595 #endif
1596 
1597 #if ETL_CPP17_SUPPORTED
1598  template <typename T, typename T1, typename... TRest>
1599  inline constexpr bool are_all_same_v = are_all_same<T, T1, TRest...>::value;
1600 #endif
1601 }
1602 
1603 #endif // ETL_TYPE_TRAITS_INCLUDED
integral_constant< bool, false > false_type
integral_constant specialisations
Definition: type_traits_generator.h:804
add_const
Definition: type_traits_generator.h:881
add_cv
Definition: type_traits_generator.h:931
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_compound
Definition: type_traits_generator.h:1021
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
add_lvalue_reference
Definition: type_traits_generator.h:1307
Definition: type_traits_generator.h:812
conditional_integral_constant
Definition: type_traits_generator.h:1366
is_class
Definition: type_traits_generator.h:1298
Definition: type_traits.h:1397
negation
Definition: type_traits.h:114
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