Embedded Template Library 1.0
Loading...
Searching...
No Matches
alignment.h
Go to the documentation of this file.
1
2
3/******************************************************************************
4The MIT License(MIT)
5
6Embedded Template Library.
7https://github.com/ETLCPP/etl
8https://www.etlcpp.com
9
10Copyright(c) 2014 John Wellbelove
11
12Permission is hereby granted, free of charge, to any person obtaining a copy
13of this software and associated documentation files(the "Software"), to deal
14in the Software without restriction, including without limitation the rights
15to use, copy, modify, merge, publish, distribute, sublicense, and / or sell
16copies of the Software, and to permit persons to whom the Software is
17furnished to do so, subject to the following conditions :
18
19The above copyright notice and this permission notice shall be included in all
20copies or substantial portions of the Software.
21
22THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
23IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
24FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE
25AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
26LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
27OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
28SOFTWARE.
29******************************************************************************/
30
31#ifndef ETL_ALIGNMENT_INCLUDED
32#define ETL_ALIGNMENT_INCLUDED
33
34#include "platform.h"
35#include "type_traits.h"
36#include "static_assert.h"
37#include "error_handler.h"
38#include "exception.h"
39#include "utility.h"
40#include "algorithm.h"
41
42#include <stdint.h>
43
47
48namespace etl
49{
50 //***************************************************************************
52 //***************************************************************************
53 class alignment_exception : public etl::exception
54 {
55 public:
56
57 alignment_exception(string_type reason_, string_type file_name_, numeric_type line_number_)
58 : exception(reason_, file_name_, line_number_)
59 {
60 }
61 };
62
63 //***************************************************************************
65 //***************************************************************************
66 class alignment_error : public alignment_exception
67 {
68 public:
69
70 alignment_error(string_type file_name_, numeric_type line_number_)
71 : alignment_exception(ETL_ERROR_TEXT("alignment:error", ETL_ALIGNMENT_FILE_ID"A"), file_name_, line_number_)
72 {
73 }
74 };
75
76 //***************************************************************************
78 //***************************************************************************
79 class typed_storage_error : public alignment_exception
80 {
81 public:
82
83 typed_storage_error(string_type file_name_, numeric_type line_number_)
84 : alignment_exception(ETL_ERROR_TEXT("typed_storage:error", ETL_ALIGNMENT_FILE_ID"B"), file_name_, line_number_)
85 {
86 }
87 };
88
89 //*****************************************************************************
91 //*****************************************************************************
92 inline bool is_aligned(const void* p, size_t required_alignment)
93 {
94 uintptr_t address = reinterpret_cast<uintptr_t>(p);
95 return (address % required_alignment) == 0U;
96 }
97
98 //*****************************************************************************
100 //*****************************************************************************
101 template <size_t Alignment>
102 bool is_aligned(const void* p)
103 {
104 uintptr_t address = reinterpret_cast<uintptr_t>(p);
105 return (address % Alignment) == 0U;
106 }
107
108 //*****************************************************************************
110 //*****************************************************************************
111 template <typename T>
112 bool is_aligned(const void* p)
113 {
115 }
116
117 namespace private_alignment
118 {
119#if ETL_USING_CPP11
120 //***************************************************************************
121 // Matcher.
122 //***************************************************************************
123 template <bool Is_Match, size_t Alignment, typename... TRest>
124 class type_with_alignment_matcher;
125
126 // Matching alignment.
127 template <size_t Alignment, typename T1, typename... TRest>
128 class type_with_alignment_matcher<true, Alignment, T1, TRest...>
129 {
130 public:
131
132 typedef T1 type;
133 };
134
135 // Non-matching alignment
136 template <size_t Alignment, typename T1, typename T2, typename... TRest>
137 class type_with_alignment_matcher <false, Alignment, T1, T2, TRest...>
138 {
139 public:
140
141 typedef typename type_with_alignment_matcher < Alignment <= etl::alignment_of<T2>::value , Alignment, T2, TRest... > ::type type;
142 };
143
144 // Non-matching alignment, none left.
145 template <size_t Alignment, typename T1>
146 class type_with_alignment_matcher <false, Alignment, T1>
147 {
148 public:
149
150 typedef char type;
151 };
152
153 //***************************************************************************
154 // Helper.
155 //***************************************************************************
156 template <size_t Alignment, typename T1, typename... T>
158 {
159 public:
160
161 typedef typename type_with_alignment_matcher<Alignment <= etl::alignment_of<T1>::value, Alignment, T1, T...>::type type;
162 };
163#else
164 //***************************************************************************
165 // Matcher.
166 //***************************************************************************
167 template <bool Is_Match, const size_t Alignment, typename T1 = void, typename T2 = void, typename T3 = void, typename T4 = void,
168 typename T5 = void, typename T6 = void, typename T7 = void, typename T8 = void>
170
171 // Matching alignment.
172 template <size_t Alignment, typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7, typename T8>
173 class type_with_alignment_matcher <true, Alignment, T1, T2, T3, T4, T5, T6, T7, T8>
174 {
175 public:
176
177 typedef T1 type;
178 };
179
180 // Non-matching alignment.
181 template <size_t Alignment, typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7, typename T8>
182 class type_with_alignment_matcher <false, Alignment, T1, T2, T3, T4, T5, T6, T7, T8>
183 {
184 public:
185
186 typedef typename type_with_alignment_matcher<Alignment <= etl::alignment_of<T2>::value, Alignment, T2, T3, T4, T5, T6, T7, T8, void>::type type;
187 };
188
189 // Non-matching alignment, none left.
190 template <size_t Alignment>
191 class type_with_alignment_matcher <false, Alignment, void, void, void, void, void, void, void, void>
192 {
193 public:
194
195 typedef char type;
196 };
197
198 //***************************************************************************
199 // Helper.
200 //***************************************************************************
201 template <size_t Alignment, typename T1, typename T2 = void, typename T3 = void, typename T4 = void,
202 typename T5 = void, typename T6 = void, typename T7 = void, typename T8 = void>
204 {
205 public:
206
207 typedef typename type_with_alignment_matcher<Alignment <= etl::alignment_of<T1>::value, Alignment, T1, T2, T3, T4, T5, T6, T7, T8>::type type;
208 };
209#endif
210 }
211
212 //***************************************************************************
215 //***************************************************************************
216 template <size_t Alignment>
218 {
219 public:
220
221#if ETL_USING_CPP11
222 typedef struct { alignas(Alignment) char dummy; } type;
223#else
224 #if ETL_NOT_USING_64BIT_TYPES
225 typedef typename private_alignment::type_with_alignment_helper<Alignment, int_least8_t, int_least16_t, int32_t, float, double, void*>::type type;
226 #else
227 typedef typename private_alignment::type_with_alignment_helper<Alignment, int_least8_t, int_least16_t, int32_t, int64_t, float, double, void*>::type type;
228 #endif
229#endif
230
231 ETL_STATIC_ASSERT(etl::alignment_of<type>::value == Alignment, "Unable to create the type with the specified alignment");
232 };
233
234#if ETL_USING_CPP11
235 template <size_t Alignment>
236 using type_with_alignment_t = typename type_with_alignment<Alignment>::type;
237#endif
238
239 //***************************************************************************
243 //***************************************************************************
244 template <size_t Length, const size_t Alignment>
246 {
247 struct type
248 {
250 template <typename T>
251 operator T& ()
252 {
253 ETL_STATIC_ASSERT((etl::is_same<T*, void*>:: value || ((Alignment % etl::alignment_of<T>::value) == 0)), "Incompatible alignment");
254 T* t = *this;
255 return *t;
256 }
257
259 template <typename T>
260 operator const T& () const
261 {
262 ETL_STATIC_ASSERT((etl::is_same<T*, void*>:: value || ((Alignment % etl::alignment_of<T>::value) == 0)), "Incompatible alignment");
263 const T* t = *this;
264 return *t;
265 }
266
268 template <typename T>
269 operator T* ()
270 {
271 ETL_STATIC_ASSERT((etl::is_same<T*, void*>:: value || ((Alignment % etl::alignment_of<T>::value) == 0)), "Incompatible alignment");
272 return reinterpret_cast<T*>(data);
273 }
274
276 template <typename T>
277 operator const T* () const
278 {
279 ETL_STATIC_ASSERT((etl::is_same<T*, void*>:: value || ((Alignment % etl::alignment_of<T>::value) == 0)), "Incompatible alignment");
280 return reinterpret_cast<const T*>(data);
281 }
282
284 template <typename T>
286 {
287 ETL_STATIC_ASSERT((etl::is_same<T*, void*>:: value || ((Alignment % etl::alignment_of<T>::value) == 0)), "Incompatible alignment");
288 T* t = *this;
289 return *t;
290 }
291
293 template <typename T>
294 const T& get_reference() const
295 {
296 ETL_STATIC_ASSERT((etl::is_same<T*, void*>:: value || ((Alignment % etl::alignment_of<T>::value) == 0)), "Incompatible alignment");
297 const T* t = *this;
298 return *t;
299 }
300
302 template <typename T>
304 {
305 ETL_STATIC_ASSERT((etl::is_same<T*, void*>:: value || ((Alignment % etl::alignment_of<T>::value) == 0)), "Incompatible alignment");
306 return reinterpret_cast<T*>(data);
307 }
308
310 template <typename T>
311 const T* get_address() const
312 {
313 ETL_STATIC_ASSERT((etl::is_same<T*, void*>:: value || ((Alignment % etl::alignment_of<T>::value) == 0)), "Incompatible alignment");
314 return reinterpret_cast<const T*>(data);
315 }
316
317#if ETL_USING_CPP11 && !defined(ETL_COMPILER_ARM5)
318 alignas(Alignment) char data[Length];
319#else
320 union
321 {
322 char data[Length];
323 typename etl::type_with_alignment<Alignment>::type etl_alignment_type; // A POD type that has the same alignment as Alignment.
324 };
325#endif
326 };
327 };
328
329#if ETL_USING_CPP11
330 template <size_t Length, const size_t Alignment>
331 using aligned_storage_t = typename aligned_storage<Length, Alignment>::type;
332#endif
333
334 //***************************************************************************
337 //***************************************************************************
338 template <size_t Length, typename T>
339 struct aligned_storage_as : public etl::aligned_storage<Length, etl::alignment_of<T>::value>
340 {
341 };
342
343#if ETL_USING_CPP11
344 template <size_t Length, typename T>
345 using aligned_storage_as_t = typename aligned_storage_as<Length, T>::type;
346#endif
347
348 //***************************************************************************
355 //***************************************************************************
356 template <typename T>
357 class typed_storage
358 {
359 public:
360
361 typedef T value_type;
362 typedef T& reference;
363 typedef const T& const_reference;
364 typedef T* pointer;
365 typedef const T* const_pointer;
366
367 //***************************************************************************
368 // Default constructor
369 //***************************************************************************
370 typed_storage() ETL_NOEXCEPT
371 : valid(false)
372 {
373 }
374
375#if ETL_USING_CPP11
376 //***************************************************************************
378 //***************************************************************************
379 template <typename... TArgs>
380 typed_storage(TArgs&&... args) ETL_NOEXCEPT_EXPR(ETL_NOT_USING_EXCEPTIONS)
381 : valid(false)
382 {
383 create(etl::forward<TArgs>(args)...);
384 }
385#else
386 //***************************************************************************
388 //***************************************************************************
389 template <typename T1>
390 typed_storage(const T1& t1)
391 : valid(false)
392 {
393 create(t1);
394 }
395
396 //***************************************************************************
398 //***************************************************************************
399 template <typename T1, typename T2>
400 typed_storage(const T1& t1, const T2& t2)
401 : valid(false)
402 {
403 create(t1, t2);
404 }
405
406 //***************************************************************************
408 //***************************************************************************
409 template <typename T1, typename T2, typename T3>
410 typed_storage(const T1& t1, const T2& t2, const T3& t3)
411 : valid(false)
412 {
413 create(t1, t2, t3);
414 }
415
416 //***************************************************************************
418 //***************************************************************************
419 template <typename T1, typename T2, typename T3, typename T4>
420 typed_storage(const T1& t1, const T2& t2, const T3& t3, const T4& t4)
421 : valid(false)
422 {
423 create(t1, t2, t3, t4);
424 }
425#endif
426
427 //***************************************************************************
430 //***************************************************************************
431 ~typed_storage() ETL_NOEXCEPT
432 {
433 // Intentionally empty.
434 }
435
436 //***************************************************************************
439 //***************************************************************************
440 bool has_value() const ETL_NOEXCEPT
441 {
442 return valid;
443 }
444
445#if ETL_USING_CPP11
446 //***************************************************************************
449 //***************************************************************************
450 template <typename... TArgs>
451 reference create(TArgs&&... args) ETL_NOEXCEPT_EXPR(ETL_NOT_USING_EXCEPTIONS)
452 {
454 pointer p = ::new (&storage.value) value_type(etl::forward<TArgs>(args)...);
455 valid = true;
456 return *p;
457 }
458#else
459 //***************************************************************************
462 //***************************************************************************
463 template <typename T1>
464 reference create(const T1& t1)
465 {
467 pointer p = ::new (&storage.value) value_type(t1);
468 valid = true;
469 return *p;
470 }
471
472 //***************************************************************************
475 //***************************************************************************
476 template <typename T1, typename T2>
477 reference create(const T1& t1, const T2& t2)
478 {
480 pointer p = ::new (&storage.value) value_type(t1, t2);
481 valid = true;
482 return *p;
483 }
484
485 //***************************************************************************
488 //***************************************************************************
489 template <typename T1, typename T2, typename T3>
490 reference create(const T1& t1, const T2& t2, const T3& t3)
491 {
493 pointer p = ::new (&storage.value) value_type(t1, t2, t3);
494 valid = true;
495 return *p;
496 }
497
498 //***************************************************************************
501 //***************************************************************************
502 template <typename T1, typename T2, typename T3, typename T4>
503 reference create(const T1& t1, const T2& t2, const T3& t3, const T4& t4)
504 {
506 pointer p = ::new (&storage.value) value_type(t1, t2, t3, t4);
507 valid = true;
508 return *p;
509 }
510#endif
511
512 //***************************************************************************
514 //***************************************************************************
515 void destroy() ETL_NOEXCEPT
516 {
517 if (has_value())
518 {
519 storage.value.~T();
520 valid = false;
521 }
522 }
523
524 //***************************************************************************
526 //***************************************************************************
527 pointer operator->() ETL_NOEXCEPT_EXPR(ETL_NOT_USING_EXCEPTIONS)
528 {
530
531 return &storage.value;
532 }
533
534 //***************************************************************************
536 //***************************************************************************
537 const_pointer operator->() const ETL_NOEXCEPT_EXPR(ETL_NOT_USING_EXCEPTIONS)
538 {
540
541 return &storage.value;
542 }
543
544 //***************************************************************************
546 //***************************************************************************
547 reference operator*() ETL_NOEXCEPT_EXPR(ETL_NOT_USING_EXCEPTIONS)
548 {
549 return *operator->();
550 }
551
552 //***************************************************************************
554 //***************************************************************************
555 const_reference operator*() const ETL_NOEXCEPT_EXPR(ETL_NOT_USING_EXCEPTIONS)
556 {
557 return *operator->();
558 }
559
560 private:
561
563 typed_storage& operator =(etl::typed_storage<T>&) ETL_DELETE;
564
565 struct dummy_t {};
566
567 //*******************************
568 union union_type
569 {
570 union_type() ETL_NOEXCEPT
571 : dummy()
572 {
573 }
574
575 ~union_type() ETL_NOEXCEPT
576 {
577 }
578
579 dummy_t dummy;
580 value_type value;
581 } storage;
582
583 bool valid;
584 };
585
586 //***************************************************************************
593 //***************************************************************************
594 template <typename T>
596 {
597 public:
598
599 typedef T value_type;
600 typedef T& reference;
601 typedef const T& const_reference;
602 typedef T* pointer;
603 typedef const T* const_pointer;
604
605 template <typename U>
606 friend ETL_CONSTEXPR14 void swap(typed_storage_ext<U>& lhs, typed_storage_ext<U>& rhs) ETL_NOEXCEPT;
607
608 //***************************************************************************
610 //***************************************************************************
611 typed_storage_ext(void* pbuffer_) ETL_NOEXCEPT_EXPR(ETL_NOT_USING_EXCEPTIONS)
612 : pbuffer(reinterpret_cast<T*>(pbuffer_)),
613 valid(false)
614 {
616 }
617
618#if ETL_USING_CPP11
619 //***************************************************************************
621 //***************************************************************************
622 template <typename... TArgs>
623 typed_storage_ext(void* pbuffer_, TArgs&&... args) ETL_NOEXCEPT_EXPR(ETL_NOT_USING_EXCEPTIONS)
624 : pbuffer(reinterpret_cast<T*>(pbuffer_))
625 , valid(false)
626 {
628 create(etl::forward<TArgs>(args)...);
629 }
630
631 //***************************************************************************
634 //***************************************************************************
635 typed_storage_ext(typed_storage_ext<T>&& other) ETL_NOEXCEPT_EXPR(ETL_NOT_USING_EXCEPTIONS)
636 : pbuffer(other.pbuffer)
637 , valid(other.valid)
638 {
639 other.pbuffer = ETL_NULLPTR;
640 other.valid = false;
641 }
642#else
643 //***************************************************************************
645 //***************************************************************************
646 template <typename T1>
647 typed_storage_ext(void* pbuffer_, const T1& t1)
648 : pbuffer(reinterpret_cast<T*>(pbuffer_))
649 , valid(false)
650 {
652 create(t1);
653 }
654
655 //***************************************************************************
657 //***************************************************************************
658 template <typename T1, typename T2>
659 typed_storage_ext(void* pbuffer_, const T1& t1, const T2& t2)
660 : pbuffer(reinterpret_cast<T*>(pbuffer_))
661 , valid(false)
662 {
664 create(t1, t2);
665 }
666
667 //***************************************************************************
669 //***************************************************************************
670 template <typename T1, typename T2, typename T3>
671 typed_storage_ext(void* pbuffer_, const T1& t1, const T2& t2, const T3& t3)
672 : pbuffer(reinterpret_cast<T*>(pbuffer_))
673 , valid(false)
674 {
676 create(t1, t2, t3);
677 }
678
679 //***************************************************************************
681 //***************************************************************************
682 template <typename T1, typename T2, typename T3, typename T4>
683 typed_storage_ext(void* pbuffer_, const T1& t1, const T2& t2, const T3& t3, const T4& t4)
684 : pbuffer(reinterpret_cast<T*>(pbuffer_))
685 , valid(false)
686 {
688 create(t1, t2, t3, t4);
689 }
690#endif
691
692 //***************************************************************************
695 //***************************************************************************
696 ~typed_storage_ext() ETL_NOEXCEPT
697 {
698 // Intentionally empty.
699 }
700
701 //***************************************************************************
704 //***************************************************************************
705 bool has_value() const ETL_NOEXCEPT
706 {
707 return valid;
708 }
709
710#if ETL_USING_CPP11
711 //***************************************************************************
714 //***************************************************************************
715 template <typename... TArgs>
716 reference create(TArgs&&... args) ETL_NOEXCEPT_EXPR(ETL_NOT_USING_EXCEPTIONS)
717 {
718 ETL_ASSERT(!has_value(), ETL_ERROR(etl::typed_storage_error));
719 pointer p = ::new (pbuffer) value_type(etl::forward<TArgs>(args)...);
720 valid = true;
721 return *p;
722 }
723#else
724 //***************************************************************************
727 //***************************************************************************
728 template <typename T1>
729 reference create(const T1& t1)
730 {
732 pointer p = ::new (pbuffer) value_type(t1);
733 valid = true;
734 return *p;
735 }
736
737 //***************************************************************************
740 //***************************************************************************
741 template <typename T1, typename T2>
742 reference create(const T1& t1, const T2& t2)
743 {
745 pointer p = ::new (pbuffer) value_type(t1, t2);
746 valid = true;
747 return *p;
748 }
749
750 //***************************************************************************
753 //***************************************************************************
754 template <typename T1, typename T2, typename T3>
755 reference create(const T1& t1, const T2& t2, const T3& t3)
756 {
758 pointer p = ::new (pbuffer) value_type(t1, t2, t3);
759 valid = true;
760 return *p;
761 }
762
763 //***************************************************************************
766 //***************************************************************************
767 template <typename T1, typename T2, typename T3, typename T4>
768 reference create(const T1& t1, const T2& t2, const T3& t3, const T4& t4)
769 {
771 pointer p = ::new (pbuffer) value_type(t1, t2, t3, t4);
772 valid = true;
773 return *p;
774 }
775#endif
776
777 //***************************************************************************
779 //***************************************************************************
780 void destroy() ETL_NOEXCEPT
781 {
782 if (has_value())
783 {
784 pbuffer->~T();
785 valid = false;
786 }
787 }
788
789 //***************************************************************************
791 //***************************************************************************
792 pointer operator->() ETL_NOEXCEPT_EXPR(ETL_NOT_USING_EXCEPTIONS)
793 {
795
796 return pbuffer;
797 }
798
799 //***************************************************************************
801 //***************************************************************************
802 const_pointer operator->() const ETL_NOEXCEPT_EXPR(ETL_NOT_USING_EXCEPTIONS)
803 {
805
806 return pbuffer;
807 }
808
809 //***************************************************************************
811 //***************************************************************************
812 reference operator*() ETL_NOEXCEPT_EXPR(ETL_NOT_USING_EXCEPTIONS)
813 {
814 return *operator->();
815 }
816
817 //***************************************************************************
819 //***************************************************************************
820 const_reference operator*() const ETL_NOEXCEPT_EXPR(ETL_NOT_USING_EXCEPTIONS)
821 {
822 return *operator->();
823 }
824
825 private:
826
828 typed_storage_ext& operator =(etl::typed_storage_ext<T>&) ETL_DELETE;
829
830 pointer pbuffer;
831 bool valid;
832 };
833
834 //***************************************************************************
836 //***************************************************************************
837 template <typename T>
838 ETL_CONSTEXPR14 void swap(etl::typed_storage_ext<T>& lhs, etl::typed_storage_ext<T>& rhs) ETL_NOEXCEPT
839 {
840 using ETL_OR_STD::swap;
841
842 swap(lhs.pbuffer, rhs.pbuffer);
843 swap(lhs.valid, rhs.valid);
844 }
845}
846
847#endif
void swap(etl::array_view< T > &lhs, etl::array_view< T > &rhs) ETL_NOEXCEPT
Swaps the values.
Definition array_view.h:650
Memory misalignment exception.
Definition alignment.h:67
Typed storage exception.
Definition alignment.h:80
Definition alignment.h:596
typed_storage_ext(void *pbuffer_) ETL_NOEXCEPT_EXPR(ETL_NOT_USING_EXCEPTIONS)
Constructor.
Definition alignment.h:611
typed_storage_ext(void *pbuffer_, const T1 &t1, const T2 &t2)
Constructs the instance of T with types T1, T2.
Definition alignment.h:659
const_reference operator*() const ETL_NOEXCEPT_EXPR(ETL_NOT_USING_EXCEPTIONS)
Definition alignment.h:820
reference create(const T1 &t1, const T2 &t2)
Definition alignment.h:742
pointer operator->() ETL_NOEXCEPT_EXPR(ETL_NOT_USING_EXCEPTIONS)
Definition alignment.h:792
reference create(const T1 &t1, const T2 &t2, const T3 &t3, const T4 &t4)
Definition alignment.h:768
reference create(const T1 &t1, const T2 &t2, const T3 &t3)
Definition alignment.h:755
typed_storage_ext(void *pbuffer_, const T1 &t1)
Constructs the instance of T with type T1.
Definition alignment.h:647
void destroy() ETL_NOEXCEPT
Calls the destructor of the stored object, if created.
Definition alignment.h:780
~typed_storage_ext() ETL_NOEXCEPT
Definition alignment.h:696
bool has_value() const ETL_NOEXCEPT
Definition alignment.h:705
typed_storage_ext(void *pbuffer_, const T1 &t1, const T2 &t2, const T3 &t3)
Constructs the instance of T with types T1, T2, T3.
Definition alignment.h:671
reference operator*() ETL_NOEXCEPT_EXPR(ETL_NOT_USING_EXCEPTIONS)
Definition alignment.h:812
typed_storage_ext(void *pbuffer_, const T1 &t1, const T2 &t2, const T3 &t3, const T4 &t4)
Constructs the instance of T with types T1, T2, T3, T4.
Definition alignment.h:683
reference create(const T1 &t1)
Definition alignment.h:729
const_pointer operator->() const ETL_NOEXCEPT_EXPR(ETL_NOT_USING_EXCEPTIONS)
Definition alignment.h:802
Definition alignment.h:358
reference create(const T1 &t1, const T2 &t2)
Definition alignment.h:477
reference create(const T1 &t1)
Definition alignment.h:464
reference operator*() ETL_NOEXCEPT_EXPR(ETL_NOT_USING_EXCEPTIONS)
Definition alignment.h:547
void destroy() ETL_NOEXCEPT
Calls the destructor of the stored object, if created.
Definition alignment.h:515
bool has_value() const ETL_NOEXCEPT
Definition alignment.h:440
typed_storage(const T1 &t1)
Constructs the instance of T with type T1.
Definition alignment.h:390
const_reference operator*() const ETL_NOEXCEPT_EXPR(ETL_NOT_USING_EXCEPTIONS)
Definition alignment.h:555
~typed_storage() ETL_NOEXCEPT
Definition alignment.h:431
const_pointer operator->() const ETL_NOEXCEPT_EXPR(ETL_NOT_USING_EXCEPTIONS)
Definition alignment.h:537
reference create(const T1 &t1, const T2 &t2, const T3 &t3)
Definition alignment.h:490
pointer operator->() ETL_NOEXCEPT_EXPR(ETL_NOT_USING_EXCEPTIONS)
Definition alignment.h:527
typed_storage(const T1 &t1, const T2 &t2, const T3 &t3, const T4 &t4)
Constructs the instance of T with types T1, T2, T3, T4.
Definition alignment.h:420
typed_storage(const T1 &t1, const T2 &t2, const T3 &t3)
Constructs the instance of T with types T1, T2, T3.
Definition alignment.h:410
reference create(const T1 &t1, const T2 &t2, const T3 &t3, const T4 &t4)
Definition alignment.h:503
typed_storage(const T1 &t1, const T2 &t2)
Constructs the instance of T with types T1, T2.
Definition alignment.h:400
Definition alignment.h:218
Definition alignment.h:246
Definition alignment.h:340
#define ETL_ASSERT(b, e)
Definition error_handler.h:356
ETL_CONSTEXPR exception(string_type reason_, string_type, numeric_type line_)
Constructor.
Definition exception.h:69
Definition exception.h:47
add_rvalue_reference
Definition type_traits_generator.h:1413
is_same
Definition type_traits_generator.h:1104
bitset_ext
Definition absolute.h:39
ETL_CONSTEXPR14 void swap(etl::typed_storage_ext< T > &lhs, etl::typed_storage_ext< T > &rhs) ETL_NOEXCEPT
Swap two etl::typed_storage_ext.
Definition alignment.h:838
T * create(Args &&... args)
Creates the object from a type. Variadic parameter constructor.
Definition variant_pool_generator.h:348
bool is_aligned(const void *p, size_t required_alignment)
Check that 'p' has 'required_alignment'.
Definition alignment.h:92
Definition alignment.h:248
const T * get_address() const
Get address as const T pointer.
Definition alignment.h:311
T * get_address()
Get address as T pointer.
Definition alignment.h:303
const T & get_reference() const
Get address as const T reference.
Definition alignment.h:294
T & get_reference()
Get address as T reference.
Definition alignment.h:285