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 "error_handler.h"
36#include "exception.h"
37#include "static_assert.h"
38#include "type_traits.h"
39#include "utility.h"
40
41#include <stdint.h>
42
46
47namespace etl
48{
49 //***************************************************************************
51 //***************************************************************************
52 class alignment_exception : public etl::exception
53 {
54 public:
55
56 alignment_exception(string_type reason_, string_type file_name_, numeric_type line_number_)
57 : exception(reason_, file_name_, line_number_)
58 {
59 }
60 };
61
62 //***************************************************************************
64 //***************************************************************************
65 class alignment_error : public alignment_exception
66 {
67 public:
68
69 alignment_error(string_type file_name_, numeric_type line_number_)
70 : alignment_exception(ETL_ERROR_TEXT("alignment:error", ETL_ALIGNMENT_FILE_ID"A"), file_name_, line_number_)
71 {
72 }
73 };
74
75 //***************************************************************************
77 //***************************************************************************
78 class typed_storage_error : public alignment_exception
79 {
80 public:
81
82 typed_storage_error(string_type file_name_, numeric_type line_number_)
83 : alignment_exception(ETL_ERROR_TEXT("typed_storage:error", ETL_ALIGNMENT_FILE_ID"B"), file_name_, line_number_)
84 {
85 }
86 };
87
88 //*****************************************************************************
90 //*****************************************************************************
91 inline bool is_aligned(const void* p, size_t required_alignment)
92 {
93 uintptr_t address = reinterpret_cast<uintptr_t>(p);
94 return (address % required_alignment) == 0U;
95 }
96
97 //*****************************************************************************
99 //*****************************************************************************
100 template <size_t Alignment>
101 bool is_aligned(const void* p)
102 {
103 uintptr_t address = reinterpret_cast<uintptr_t>(p);
104 return (address % Alignment) == 0U;
105 }
106
107 //*****************************************************************************
109 //*****************************************************************************
110 template <typename T>
111 bool is_aligned(const void* p)
112 {
114 }
115
116 namespace private_alignment
117 {
118#if ETL_USING_CPP11
119 //***************************************************************************
120 // Matcher.
121 //***************************************************************************
122 template <bool Is_Match, size_t Alignment, typename... TRest>
123 class type_with_alignment_matcher;
124
125 // Matching alignment.
126 template <size_t Alignment, typename T1, typename... TRest>
127 class type_with_alignment_matcher<true, Alignment, T1, TRest...>
128 {
129 public:
130
131 typedef T1 type;
132 };
133
134 // Non-matching alignment
135 template <size_t Alignment, typename T1, typename T2, typename... TRest>
136 class type_with_alignment_matcher<false, Alignment, T1, T2, TRest...>
137 {
138 public:
139
140 typedef typename type_with_alignment_matcher< Alignment <= etl::alignment_of<T2>::value, Alignment, T2, TRest... >::type type;
141 };
142
143 // Non-matching alignment, none left.
144 template <size_t Alignment, typename T1>
145 class type_with_alignment_matcher<false, Alignment, T1>
146 {
147 public:
148
149 typedef char type;
150 };
151
152 //***************************************************************************
153 // Helper.
154 //***************************************************************************
155 template <size_t Alignment, typename T1, typename... T>
157 {
158 public:
159
160 typedef typename type_with_alignment_matcher<Alignment <= etl::alignment_of<T1>::value, Alignment, T1, T...>::type type;
161 };
162#else
163 //***************************************************************************
164 // Matcher.
165 //***************************************************************************
166 template <bool Is_Match, const size_t Alignment, typename T1 = void, typename T2 = void, typename T3 = void, typename T4 = void,
167 typename T5 = void, typename T6 = void, typename T7 = void, typename T8 = void>
169
170 // Matching alignment.
171 template <size_t Alignment, typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7, typename T8>
172 class type_with_alignment_matcher<true, Alignment, T1, T2, T3, T4, T5, T6, T7, T8>
173 {
174 public:
175
176 typedef T1 type;
177 };
178
179 // Non-matching alignment.
180 template <size_t Alignment, typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7, typename T8>
181 class type_with_alignment_matcher<false, Alignment, T1, T2, T3, T4, T5, T6, T7, T8>
182 {
183 public:
184
185 typedef
186 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, typename T5 = void, typename T6 = void,
202 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 } // namespace private_alignment
211
212 //***************************************************************************
215 //***************************************************************************
216 template <size_t Alignment>
218 {
219 public:
220
221#if ETL_USING_CPP11
222 typedef struct
223 {
224 alignas(Alignment) char dummy;
225 } type;
226#else
227 #if ETL_NOT_USING_64BIT_TYPES
228 typedef typename private_alignment::type_with_alignment_helper< Alignment, int_least8_t, int_least16_t, int32_t, float, double, void*>::type type;
229 #else
230 typedef
231 typename private_alignment::type_with_alignment_helper< Alignment, int_least8_t, int_least16_t, int32_t, int64_t, float, double, void*>::type
232 type;
233 #endif
234#endif
235
236 ETL_STATIC_ASSERT(etl::alignment_of<type>::value == Alignment, "Unable to create the type with the specified alignment");
237 };
238
239#if ETL_USING_CPP11
240 template <size_t Alignment>
241 using type_with_alignment_t = typename type_with_alignment<Alignment>::type;
242#endif
243
244 //***************************************************************************
248 //***************************************************************************
249 template <size_t Length, const size_t Alignment>
251 {
252 struct type
253 {
255 template <typename T>
256 operator T&()
257 {
258 ETL_STATIC_ASSERT((etl::is_same<T*, void*>::value || ((Alignment % etl::alignment_of<T>::value) == 0)), "Incompatible alignment");
259 T* t = *this;
260 return *t;
261 }
262
264 template <typename T>
265 operator const T&() const
266 {
267 ETL_STATIC_ASSERT((etl::is_same<T*, void*>::value || ((Alignment % etl::alignment_of<T>::value) == 0)), "Incompatible alignment");
268 const T* t = *this;
269 return *t;
270 }
271
273 template <typename T>
274 operator T*()
275 {
276 ETL_STATIC_ASSERT((etl::is_same<T*, void*>::value || ((Alignment % etl::alignment_of<T>::value) == 0)), "Incompatible alignment");
277 return reinterpret_cast<T*>(data);
278 }
279
281 template <typename T>
282 operator const T*() const
283 {
284 ETL_STATIC_ASSERT((etl::is_same<T*, void*>::value || ((Alignment % etl::alignment_of<T>::value) == 0)), "Incompatible alignment");
285 return reinterpret_cast<const T*>(data);
286 }
287
289 template <typename T>
291 {
292 ETL_STATIC_ASSERT((etl::is_same<T*, void*>::value || ((Alignment % etl::alignment_of<T>::value) == 0)), "Incompatible alignment");
293 T* t = *this;
294 return *t;
295 }
296
298 template <typename T>
299 const T& get_reference() const
300 {
301 ETL_STATIC_ASSERT((etl::is_same<T*, void*>::value || ((Alignment % etl::alignment_of<T>::value) == 0)), "Incompatible alignment");
302 const T* t = *this;
303 return *t;
304 }
305
307 template <typename T>
309 {
310 ETL_STATIC_ASSERT((etl::is_same<T*, void*>::value || ((Alignment % etl::alignment_of<T>::value) == 0)), "Incompatible alignment");
311 return reinterpret_cast<T*>(data);
312 }
313
315 template <typename T>
316 const T* get_address() const
317 {
318 ETL_STATIC_ASSERT((etl::is_same<T*, void*>::value || ((Alignment % etl::alignment_of<T>::value) == 0)), "Incompatible alignment");
319 return reinterpret_cast<const T*>(data);
320 }
321
322#if ETL_USING_CPP11 && !defined(ETL_COMPILER_ARM5)
323 alignas(Alignment) char data[Length];
324#else
325 union
326 {
327 char data[Length];
328 typename etl::type_with_alignment<Alignment>::type etl_alignment_type; // A POD type that has the same alignment
329 // as Alignment.
330 };
331#endif
332 };
333 };
334
335#if ETL_USING_CPP11
336 template <size_t Length, const size_t Alignment>
337 using aligned_storage_t = typename aligned_storage<Length, Alignment>::type;
338#endif
339
340 //***************************************************************************
343 //***************************************************************************
344 template <size_t Length, typename T>
345 struct aligned_storage_as : public etl::aligned_storage<Length, etl::alignment_of<T>::value>
346 {
347 };
348
349#if ETL_USING_CPP11
350 template <size_t Length, typename T>
351 using aligned_storage_as_t = typename aligned_storage_as<Length, T>::type;
352#endif
353
354 //***************************************************************************
361 //***************************************************************************
362 template <typename T>
363 class typed_storage
364 {
365 public:
366
367 typedef T value_type;
368 typedef T& reference;
369 typedef const T& const_reference;
370 typedef T* pointer;
371 typedef const T* const_pointer;
372
373 //***************************************************************************
374 // Default constructor
375 //***************************************************************************
376 ETL_CONSTEXPR typed_storage() ETL_NOEXCEPT
377 : valid(false)
378 {
379 }
380
381#if ETL_USING_CPP11
382 //***************************************************************************
385 //***************************************************************************
386 template <typename... TArgs>
387 typed_storage(TArgs&&... args) ETL_NOEXCEPT_EXPR(ETL_NOT_USING_EXCEPTIONS)
388 : valid(false)
389 {
390 create(etl::forward<TArgs>(args)...);
391 }
392#else
393 //***************************************************************************
395 //***************************************************************************
396 template <typename T1>
397 typed_storage(const T1& t1)
398 : valid(false)
399 {
400 create(t1);
401 }
402
403 //***************************************************************************
405 //***************************************************************************
406 template <typename T1, typename T2>
407 typed_storage(const T1& t1, const T2& t2)
408 : valid(false)
409 {
410 create(t1, t2);
411 }
412
413 //***************************************************************************
415 //***************************************************************************
416 template <typename T1, typename T2, typename T3>
417 typed_storage(const T1& t1, const T2& t2, const T3& t3)
418 : valid(false)
419 {
420 create(t1, t2, t3);
421 }
422
423 //***************************************************************************
425 //***************************************************************************
426 template <typename T1, typename T2, typename T3, typename T4>
427 typed_storage(const T1& t1, const T2& t2, const T3& t3, const T4& t4)
428 : valid(false)
429 {
430 create(t1, t2, t3, t4);
431 }
432#endif
433
434 //***************************************************************************
437 //***************************************************************************
438 ~typed_storage() ETL_NOEXCEPT
439 {
440 // Intentionally empty.
441 }
442
443 //***************************************************************************
446 //***************************************************************************
447 bool has_value() const ETL_NOEXCEPT
448 {
449 return valid;
450 }
451
452#if ETL_USING_CPP11
453 //***************************************************************************
457 //***************************************************************************
458 template <typename... TArgs>
459 reference create(TArgs&&... args) ETL_NOEXCEPT_EXPR(ETL_NOT_USING_EXCEPTIONS)
460 {
462 pointer p = ::new (&storage.value) value_type(etl::forward<TArgs>(args)...);
463 valid = true;
464 return *p;
465 }
466#else
467 //***************************************************************************
471 //***************************************************************************
472 template <typename T1>
473 reference create(const T1& t1)
474 {
476 pointer p = ::new (&storage.value) value_type(t1);
477 valid = true;
478 return *p;
479 }
480
481 //***************************************************************************
485 //***************************************************************************
486 template <typename T1, typename T2>
487 reference create(const T1& t1, const T2& t2)
488 {
490 pointer p = ::new (&storage.value) value_type(t1, t2);
491 valid = true;
492 return *p;
493 }
494
495 //***************************************************************************
499 //***************************************************************************
500 template <typename T1, typename T2, typename T3>
501 reference create(const T1& t1, const T2& t2, const T3& t3)
502 {
504 pointer p = ::new (&storage.value) value_type(t1, t2, t3);
505 valid = true;
506 return *p;
507 }
508
509 //***************************************************************************
513 //***************************************************************************
514 template <typename T1, typename T2, typename T3, typename T4>
515 reference create(const T1& t1, const T2& t2, const T3& t3, const T4& t4)
516 {
518 pointer p = ::new (&storage.value) value_type(t1, t2, t3, t4);
519 valid = true;
520 return *p;
521 }
522#endif
523
524 //***************************************************************************
526 //***************************************************************************
527 void destroy() ETL_NOEXCEPT
528 {
529 if (has_value())
530 {
531 storage.value.~T();
532 valid = false;
533 }
534 }
535
536 //***************************************************************************
538 //***************************************************************************
539 pointer operator->() ETL_NOEXCEPT_EXPR(ETL_NOT_USING_EXCEPTIONS)
540 {
542
543 return &storage.value;
544 }
545
546 //***************************************************************************
548 //***************************************************************************
549 const_pointer operator->() const ETL_NOEXCEPT_EXPR(ETL_NOT_USING_EXCEPTIONS)
550 {
552
553 return &storage.value;
554 }
555
556 //***************************************************************************
558 //***************************************************************************
559 reference operator*() ETL_NOEXCEPT_EXPR(ETL_NOT_USING_EXCEPTIONS)
560 {
561 return *operator->();
562 }
563
564 //***************************************************************************
566 //***************************************************************************
567 const_reference operator*() const ETL_NOEXCEPT_EXPR(ETL_NOT_USING_EXCEPTIONS)
568 {
569 return *operator->();
570 }
571
572 private:
573
575 typed_storage& operator=(etl::typed_storage<T>&) ETL_DELETE;
576
577 struct dummy_t
578 {
579 };
580
581 //*******************************
582 union union_type
583 {
584 ETL_CONSTEXPR union_type() ETL_NOEXCEPT
585 : dummy()
586 {
587 }
588
589 ~union_type() ETL_NOEXCEPT {}
590
591 dummy_t dummy;
592 value_type value;
593 } storage;
594
595 bool valid;
596 };
597
598 //***************************************************************************
605 //***************************************************************************
606 template <typename T>
608 {
609 public:
610
611 typedef T value_type;
612 typedef T& reference;
613 typedef const T& const_reference;
614 typedef T* pointer;
615 typedef const T* const_pointer;
616
617 template <typename U>
618 friend ETL_CONSTEXPR14 void swap(typed_storage_ext<U>& lhs, typed_storage_ext<U>& rhs) ETL_NOEXCEPT;
619
620 //***************************************************************************
622 //***************************************************************************
623 typed_storage_ext(void* pbuffer_) ETL_NOEXCEPT_EXPR(ETL_NOT_USING_EXCEPTIONS)
624 : pbuffer(reinterpret_cast<T*>(pbuffer_))
625 , valid(false)
626 {
627 ETL_ASSERT(etl::is_aligned(pbuffer_, etl::alignment_of<T>::value), ETL_ERROR(etl::alignment_error));
628 }
629
630#if ETL_USING_CPP11
631 //***************************************************************************
634 //***************************************************************************
635 template <typename... TArgs>
636 typed_storage_ext(void* pbuffer_, TArgs&&... args) ETL_NOEXCEPT_EXPR(ETL_NOT_USING_EXCEPTIONS)
637 : pbuffer(reinterpret_cast<T*>(pbuffer_))
638 , valid(false)
639 {
640 ETL_ASSERT(etl::is_aligned(pbuffer_, etl::alignment_of<T>::value), ETL_ERROR(etl::alignment_error));
641 create(etl::forward<TArgs>(args)...);
642 }
643
644 //***************************************************************************
647 //***************************************************************************
648 typed_storage_ext(typed_storage_ext<T>&& other) ETL_NOEXCEPT_EXPR(ETL_NOT_USING_EXCEPTIONS)
649 : pbuffer(other.pbuffer)
650 , valid(other.valid)
651 {
652 other.pbuffer = ETL_NULLPTR;
653 other.valid = false;
654 }
655#else
656 //***************************************************************************
658 //***************************************************************************
659 template <typename T1>
660 typed_storage_ext(void* pbuffer_, const T1& t1)
661 : pbuffer(reinterpret_cast<T*>(pbuffer_))
662 , valid(false)
663 {
664 ETL_ASSERT(etl::is_aligned(pbuffer_, etl::alignment_of<T>::value), ETL_ERROR(etl::alignment_error));
665 create(t1);
666 }
667
668 //***************************************************************************
670 //***************************************************************************
671 template <typename T1, typename T2>
672 typed_storage_ext(void* pbuffer_, const T1& t1, const T2& t2)
673 : pbuffer(reinterpret_cast<T*>(pbuffer_))
674 , valid(false)
675 {
676 ETL_ASSERT(etl::is_aligned(pbuffer_, etl::alignment_of<T>::value), ETL_ERROR(etl::alignment_error));
677 create(t1, t2);
678 }
679
680 //***************************************************************************
682 //***************************************************************************
683 template <typename T1, typename T2, typename T3>
684 typed_storage_ext(void* pbuffer_, const T1& t1, const T2& t2, const T3& t3)
685 : pbuffer(reinterpret_cast<T*>(pbuffer_))
686 , valid(false)
687 {
688 ETL_ASSERT(etl::is_aligned(pbuffer_, etl::alignment_of<T>::value), ETL_ERROR(etl::alignment_error));
689 create(t1, t2, t3);
690 }
691
692 //***************************************************************************
694 //***************************************************************************
695 template <typename T1, typename T2, typename T3, typename T4>
696 typed_storage_ext(void* pbuffer_, const T1& t1, const T2& t2, const T3& t3, const T4& t4)
697 : pbuffer(reinterpret_cast<T*>(pbuffer_))
698 , valid(false)
699 {
700 ETL_ASSERT(etl::is_aligned(pbuffer_, etl::alignment_of<T>::value), ETL_ERROR(etl::alignment_error));
701 create(t1, t2, t3, t4);
702 }
703#endif
704
705 //***************************************************************************
708 //***************************************************************************
709 ~typed_storage_ext() ETL_NOEXCEPT
710 {
711 // Intentionally empty.
712 }
713
714 //***************************************************************************
717 //***************************************************************************
718 bool has_value() const ETL_NOEXCEPT
719 {
720 return valid;
721 }
722
723#if ETL_USING_CPP11
724 //***************************************************************************
728 //***************************************************************************
729 template <typename... TArgs>
730 reference create(TArgs&&... args) ETL_NOEXCEPT_EXPR(ETL_NOT_USING_EXCEPTIONS)
731 {
732 ETL_ASSERT(!has_value(), ETL_ERROR(etl::typed_storage_error));
733 pointer p = ::new (pbuffer) value_type(etl::forward<TArgs>(args)...);
734 valid = true;
735 return *p;
736 }
737#else
738 //***************************************************************************
742 //***************************************************************************
743 template <typename T1>
744 reference create(const T1& t1)
745 {
747 pointer p = ::new (pbuffer) value_type(t1);
748 valid = true;
749 return *p;
750 }
751
752 //***************************************************************************
756 //***************************************************************************
757 template <typename T1, typename T2>
758 reference create(const T1& t1, const T2& t2)
759 {
761 pointer p = ::new (pbuffer) value_type(t1, t2);
762 valid = true;
763 return *p;
764 }
765
766 //***************************************************************************
770 //***************************************************************************
771 template <typename T1, typename T2, typename T3>
772 reference create(const T1& t1, const T2& t2, const T3& t3)
773 {
775 pointer p = ::new (pbuffer) value_type(t1, t2, t3);
776 valid = true;
777 return *p;
778 }
779
780 //***************************************************************************
784 //***************************************************************************
785 template <typename T1, typename T2, typename T3, typename T4>
786 reference create(const T1& t1, const T2& t2, const T3& t3, const T4& t4)
787 {
789 pointer p = ::new (pbuffer) value_type(t1, t2, t3, t4);
790 valid = true;
791 return *p;
792 }
793#endif
794
795 //***************************************************************************
797 //***************************************************************************
798 void destroy() ETL_NOEXCEPT
799 {
800 if (has_value())
801 {
802 pbuffer->~T();
803 valid = false;
804 }
805 }
806
807 //***************************************************************************
809 //***************************************************************************
810 pointer operator->() ETL_NOEXCEPT_EXPR(ETL_NOT_USING_EXCEPTIONS)
811 {
813
814 return pbuffer;
815 }
816
817 //***************************************************************************
819 //***************************************************************************
820 const_pointer operator->() const ETL_NOEXCEPT_EXPR(ETL_NOT_USING_EXCEPTIONS)
821 {
823
824 return pbuffer;
825 }
826
827 //***************************************************************************
829 //***************************************************************************
830 reference operator*() ETL_NOEXCEPT_EXPR(ETL_NOT_USING_EXCEPTIONS)
831 {
832 return *operator->();
833 }
834
835 //***************************************************************************
837 //***************************************************************************
838 const_reference operator*() const ETL_NOEXCEPT_EXPR(ETL_NOT_USING_EXCEPTIONS)
839 {
840 return *operator->();
841 }
842
843 private:
844
846 typed_storage_ext& operator=(etl::typed_storage_ext<T>&) ETL_DELETE;
847
848 pointer pbuffer;
849 bool valid;
850 };
851
852 //***************************************************************************
854 //***************************************************************************
855 template <typename T>
856 ETL_CONSTEXPR14 void swap(etl::typed_storage_ext<T>& lhs, etl::typed_storage_ext<T>& rhs) ETL_NOEXCEPT
857 {
858 using ETL_OR_STD::swap;
859
860 swap(lhs.pbuffer, rhs.pbuffer);
861 swap(lhs.valid, rhs.valid);
862 }
863} // namespace etl
864
865#endif
void swap(etl::array_view< T > &lhs, etl::array_view< T > &rhs) ETL_NOEXCEPT
Swaps the values.
Definition array_view.h:692
Memory misalignment exception.
Definition alignment.h:66
Typed storage exception.
Definition alignment.h:79
Definition alignment.h:608
typed_storage_ext(void *pbuffer_) ETL_NOEXCEPT_EXPR(ETL_NOT_USING_EXCEPTIONS)
Constructor.
Definition alignment.h:623
typed_storage_ext(void *pbuffer_, const T1 &t1, const T2 &t2)
Constructs the instance of T with types T1, T2.
Definition alignment.h:672
const_reference operator*() const ETL_NOEXCEPT_EXPR(ETL_NOT_USING_EXCEPTIONS)
Definition alignment.h:838
reference create(const T1 &t1, const T2 &t2)
Definition alignment.h:758
pointer operator->() ETL_NOEXCEPT_EXPR(ETL_NOT_USING_EXCEPTIONS)
Definition alignment.h:810
reference create(const T1 &t1, const T2 &t2, const T3 &t3, const T4 &t4)
Definition alignment.h:786
reference create(const T1 &t1, const T2 &t2, const T3 &t3)
Definition alignment.h:772
typed_storage_ext(void *pbuffer_, const T1 &t1)
Constructs the instance of T with type T1.
Definition alignment.h:660
void destroy() ETL_NOEXCEPT
Calls the destructor of the stored object, if created.
Definition alignment.h:798
~typed_storage_ext() ETL_NOEXCEPT
Definition alignment.h:709
bool has_value() const ETL_NOEXCEPT
Definition alignment.h:718
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:684
reference operator*() ETL_NOEXCEPT_EXPR(ETL_NOT_USING_EXCEPTIONS)
Definition alignment.h:830
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:696
reference create(const T1 &t1)
Definition alignment.h:744
const_pointer operator->() const ETL_NOEXCEPT_EXPR(ETL_NOT_USING_EXCEPTIONS)
Definition alignment.h:820
Definition alignment.h:364
reference create(const T1 &t1, const T2 &t2)
Definition alignment.h:487
reference create(const T1 &t1)
Definition alignment.h:473
reference operator*() ETL_NOEXCEPT_EXPR(ETL_NOT_USING_EXCEPTIONS)
Definition alignment.h:559
void destroy() ETL_NOEXCEPT
Calls the destructor of the stored object, if created.
Definition alignment.h:527
bool has_value() const ETL_NOEXCEPT
Definition alignment.h:447
typed_storage(const T1 &t1)
Constructs the instance of T with type T1.
Definition alignment.h:397
const_reference operator*() const ETL_NOEXCEPT_EXPR(ETL_NOT_USING_EXCEPTIONS)
Definition alignment.h:567
~typed_storage() ETL_NOEXCEPT
Definition alignment.h:438
const_pointer operator->() const ETL_NOEXCEPT_EXPR(ETL_NOT_USING_EXCEPTIONS)
Definition alignment.h:549
reference create(const T1 &t1, const T2 &t2, const T3 &t3)
Definition alignment.h:501
pointer operator->() ETL_NOEXCEPT_EXPR(ETL_NOT_USING_EXCEPTIONS)
Definition alignment.h:539
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:427
typed_storage(const T1 &t1, const T2 &t2, const T3 &t3)
Constructs the instance of T with types T1, T2, T3.
Definition alignment.h:417
reference create(const T1 &t1, const T2 &t2, const T3 &t3, const T4 &t4)
Definition alignment.h:515
typed_storage(const T1 &t1, const T2 &t2)
Constructs the instance of T with types T1, T2.
Definition alignment.h:407
Definition alignment.h:218
Definition alignment.h:251
Definition alignment.h:346
#define ETL_ASSERT(b, e)
Definition error_handler.h:511
ETL_EXCEPTION_CONSTEXPR exception(string_type reason_, string_type, numeric_type)
Constructor.
Definition exception.h:81
Definition exception.h:59
bitset_ext
Definition absolute.h:40
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:856
ETL_CONSTEXPR TContainer::pointer data(TContainer &container)
Definition iterator.h:1228
bool is_aligned(const void *p, size_t required_alignment)
Check that 'p' has 'required_alignment'.
Definition alignment.h:91
Definition alignment.h:253
const T * get_address() const
Get address as const T pointer.
Definition alignment.h:316
T * get_address()
Get address as T pointer.
Definition alignment.h:308
const T & get_reference() const
Get address as const T reference.
Definition alignment.h:299
T & get_reference()
Get address as T reference.
Definition alignment.h:290