Embedded Template Library 1.0
Loading...
Searching...
No Matches
array.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_ARRAY_INCLUDED
32#define ETL_ARRAY_INCLUDED
33
34#include "platform.h"
35#include "algorithm.h"
36#include "iterator.h"
37#include "functional.h"
38#include "exception.h"
39#include "type_traits.h"
40#include "parameter_type.h"
41#include "static_assert.h"
42#include "error_handler.h"
43#include "nth_type.h"
44#include "initializer_list.h"
45
46#include <stddef.h>
47
51
52namespace etl
53{
54 //***************************************************************************
57 //***************************************************************************
58 class array_exception : public exception
59 {
60 public:
61
62 array_exception(string_type reason_, string_type file_name_, numeric_type line_number_)
63 : exception(reason_, file_name_, line_number_)
64 {
65 }
66 };
67
68 //***************************************************************************
71 //***************************************************************************
72 class array_out_of_range : public array_exception
73 {
74 public:
75
76 array_out_of_range(string_type file_name_, numeric_type line_number_)
77 : array_exception("array:range", file_name_, line_number_)
78 {
79 }
80 };
81
82 //***************************************************************************
85 //***************************************************************************
86 template <typename T, size_t SIZE_>
87 class array
88 {
89 private:
90
91 typedef typename etl::parameter_type<T>::type parameter_t;
92
93 public:
94
95 static ETL_CONSTANT size_t SIZE = SIZE_;
96
97 typedef T value_type;
98 typedef size_t size_type;
99 typedef ptrdiff_t difference_type;
100 typedef T& reference;
101 typedef const T& const_reference;
102 typedef T* pointer;
103 typedef const T* const_pointer;
104 typedef T* iterator;
105 typedef const T* const_iterator;
106 typedef ETL_OR_STD::reverse_iterator<iterator> reverse_iterator;
107 typedef ETL_OR_STD::reverse_iterator<const_iterator> const_reverse_iterator;
108
109 //*************************************************************************
110 // Element access
111 //*************************************************************************
112
113 //*************************************************************************
116 //*************************************************************************
117 ETL_NODISCARD
118 ETL_CONSTEXPR14
119 reference at(size_t i) ETL_NOEXCEPT_EXPR(ETL_NOT_USING_EXCEPTIONS)
120 {
121 ETL_ASSERT(i < SIZE, ETL_ERROR(array_out_of_range));
122
123 return _buffer[i];
124 }
125
126 //*************************************************************************
129 //*************************************************************************
130 ETL_NODISCARD
131 ETL_CONSTEXPR14
132 const_reference at(size_t i) const ETL_NOEXCEPT_EXPR(ETL_NOT_USING_EXCEPTIONS)
133 {
134 ETL_ASSERT(i < SIZE, ETL_ERROR(array_out_of_range));
135
136 return _buffer[i];
137 }
138
139 //*************************************************************************
143 //*************************************************************************
144 ETL_NODISCARD
145 ETL_CONSTEXPR14
146 reference operator[](size_t i) ETL_NOEXCEPT_EXPR(ETL_NOT_USING_EXCEPTIONS || ETL_NOT_CHECKING_INDEX_OPERATOR)
147 {
148 ETL_ASSERT_CHECK_INDEX_OPERATOR(i < SIZE, ETL_ERROR(array_out_of_range));
149
150 return _buffer[i];
151 }
152
153 //*************************************************************************
157 //*************************************************************************
158 ETL_NODISCARD
159 ETL_CONSTEXPR const_reference operator[](size_t i) const ETL_NOEXCEPT_EXPR(ETL_NOT_USING_EXCEPTIONS || ETL_NOT_CHECKING_INDEX_OPERATOR)
160 {
161 // Throwing from c++11 constexpr requires special syntax
162#if ETL_USING_CPP11 && ETL_NOT_USING_CPP14 && ETL_USING_EXCEPTIONS && ETL_CHECKING_INDEX_OPERATOR
163 return i < SIZE ? _buffer[i] : throw(ETL_ERROR(array_out_of_range));
164#else
165 ETL_ASSERT_CHECK_INDEX_OPERATOR(i < SIZE, ETL_ERROR(array_out_of_range));
166
167 return _buffer[i];
168#endif
169 }
170
171 //*************************************************************************
173 //*************************************************************************
174 ETL_NODISCARD
175 ETL_CONSTEXPR14
176 reference front() ETL_NOEXCEPT
177 {
178 ETL_STATIC_ASSERT(SIZE > 0, "Array is empty.");
179
180 return _buffer[0];
181 }
182
183 //*************************************************************************
185 //*************************************************************************
186 ETL_NODISCARD
187 ETL_CONSTEXPR const_reference front() const ETL_NOEXCEPT
188 {
189 ETL_STATIC_ASSERT(SIZE > 0, "Array is empty.");
190
191 return _buffer[0];
192 }
193
194 //*************************************************************************
196 //*************************************************************************
197 ETL_NODISCARD
198 ETL_CONSTEXPR14
199 reference back() ETL_NOEXCEPT
200 {
201 ETL_STATIC_ASSERT(SIZE > 0, "Array is empty.");
202
203 return _buffer[SIZE - 1];
204 }
205
206 //*************************************************************************
208 //*************************************************************************
209 ETL_NODISCARD
210 ETL_CONSTEXPR const_reference back() const ETL_NOEXCEPT
211 {
212 ETL_STATIC_ASSERT(SIZE > 0, "Array is empty.");
213
214 return _buffer[SIZE - 1];
215 }
216
217 //*************************************************************************
219 //*************************************************************************
220 ETL_NODISCARD
221 ETL_CONSTEXPR14
222 pointer data() ETL_NOEXCEPT
223 {
224 return _buffer;
225 }
226
227 //*************************************************************************
229 //*************************************************************************
230 ETL_NODISCARD
231 ETL_CONSTEXPR const_pointer data() const ETL_NOEXCEPT
232 {
233 return _buffer;
234 }
235
236 //*************************************************************************
237 // Iterators
238 //*************************************************************************
239
240 //*************************************************************************
242 //*************************************************************************
243 ETL_NODISCARD
244 ETL_CONSTEXPR14
245 iterator begin() ETL_NOEXCEPT
246 {
247 return _buffer;
248 }
249
250 //*************************************************************************
252 //*************************************************************************
253 ETL_NODISCARD
254 ETL_CONSTEXPR const_iterator begin() const ETL_NOEXCEPT
255 {
256 return _buffer;
257 }
258
259 //*************************************************************************
261 //*************************************************************************
262 ETL_NODISCARD
263 ETL_CONSTEXPR const_iterator cbegin() const ETL_NOEXCEPT
264 {
265 return begin();
266 }
267
268 //*************************************************************************
270 //*************************************************************************
271 ETL_NODISCARD
272 ETL_CONSTEXPR14
273 iterator end() ETL_NOEXCEPT
274 {
275 return _buffer + SIZE;
276 }
277
278 //*************************************************************************
280 //*************************************************************************
281 ETL_NODISCARD
282 ETL_CONSTEXPR const_iterator end() const ETL_NOEXCEPT
283 {
284 return _buffer + SIZE;
285 }
286
287 //*************************************************************************
288 // Returns a const iterator to the end of the array.
289 //*************************************************************************
290 ETL_NODISCARD
291 ETL_CONSTEXPR const_iterator cend() const ETL_NOEXCEPT
292 {
293 return _buffer + SIZE;
294 }
295
296 //*************************************************************************
297 // Returns an reverse iterator to the reverse beginning of the array.
298 //*************************************************************************
299 ETL_NODISCARD
300 ETL_CONSTEXPR14
301 reverse_iterator rbegin() ETL_NOEXCEPT
302 {
303 return reverse_iterator(end());
304 }
305
306 //*************************************************************************
308 //*************************************************************************
309 ETL_NODISCARD
310 ETL_CONSTEXPR const_reverse_iterator rbegin() const ETL_NOEXCEPT
311 {
312 return const_reverse_iterator(end());
313 }
314
315 //*************************************************************************
317 //*************************************************************************
318 ETL_NODISCARD
319 ETL_CONSTEXPR const_reverse_iterator crbegin() const ETL_NOEXCEPT
320 {
321 return const_reverse_iterator(end());
322 }
323
324 //*************************************************************************
326 //*************************************************************************
327 ETL_NODISCARD
328 ETL_CONSTEXPR14
329 reverse_iterator rend() ETL_NOEXCEPT
330 {
331 return reverse_iterator(begin());
332 }
333
334 //*************************************************************************
336 //*************************************************************************
337 ETL_NODISCARD
338 ETL_CONSTEXPR const_reverse_iterator rend() const ETL_NOEXCEPT
339 {
340 return const_reverse_iterator(begin());
341 }
342
343 //*************************************************************************
345 //*************************************************************************
346 ETL_NODISCARD
347 ETL_CONSTEXPR const_reverse_iterator crend() const ETL_NOEXCEPT
348 {
349 return const_reverse_iterator(begin());
350 }
351
352 //*************************************************************************
353 // Capacity
354 //*************************************************************************
355
356 //*************************************************************************
358 //*************************************************************************
359 ETL_NODISCARD
360 ETL_CONSTEXPR bool empty() const ETL_NOEXCEPT
361 {
362 return (SIZE == 0);
363 }
364
365 //*************************************************************************
367 //*************************************************************************
368 ETL_NODISCARD
369 ETL_CONSTEXPR size_t size() const ETL_NOEXCEPT
370 {
371 return SIZE;
372 }
373
374 //*************************************************************************
376 //*************************************************************************
377 ETL_NODISCARD
378 ETL_CONSTEXPR size_t max_size() const ETL_NOEXCEPT
379 {
380 return SIZE;
381 }
382
383 //*************************************************************************
384 // Operations
385 //*************************************************************************
386
387 //*************************************************************************
390 //*************************************************************************
391 ETL_CONSTEXPR14 void fill(parameter_t value)
392 {
393 etl::fill(_buffer, _buffer + SIZE, value);
394 }
395
396 //*************************************************************************
399 //*************************************************************************
400 ETL_CONSTEXPR14 void swap(array& other) ETL_NOEXCEPT_FROM(ETL_OR_STD::swap(etl::declval<T&>(), etl::declval<T&>()))
401 {
402 using ETL_OR_STD::swap; // Allow ADL
403
404 for (size_t i = 0UL; i < SIZE; ++i)
405 {
406 swap(_buffer[i], other._buffer[i]);
407 }
408 }
409
410 //*************************************************************************
416 //*************************************************************************
417 template <typename TIterator>
418 iterator assign(TIterator first, const TIterator last)
419 {
420 return etl::copy_s(first, last, begin(), end());
421 }
422
423 //*************************************************************************
429 //*************************************************************************
430 template <typename TIterator>
431 iterator assign(TIterator first, const TIterator last, parameter_t value)
432 {
433 // Copy from the range.
434 iterator p = etl::copy_s(first, last, begin(), end());
435
436 // Initialise any that are left.
437 etl::fill(p, end(), value);
438
439 return p;
440 }
441
442 //*************************************************************************
446 //*************************************************************************
447 inline iterator insert_at(size_t position, parameter_t value)
448 {
449 ETL_ASSERT_CHECK_EXTRA(position < SIZE, ETL_ERROR(array_out_of_range));
450
451 return insert(begin() + position, value);
452 }
453
454 //*************************************************************************
458 //*************************************************************************
459 iterator insert(const_iterator position, parameter_t value)
460 {
461 ETL_ASSERT_CHECK_EXTRA(cbegin() <= position && position < cend(), ETL_ERROR(array_out_of_range));
462
463 iterator p = to_iterator(position);
464
465 etl::move_backward(p, end() - 1, end());
466 *p = value;
467
468 return p;
469 }
470
471 //*************************************************************************
476 //*************************************************************************
477 template <typename TIterator>
478 inline iterator insert_at(size_t position, TIterator first, const TIterator last)
479 {
480 ETL_ASSERT_CHECK_EXTRA(position < SIZE, ETL_ERROR(array_out_of_range));
481
482 return insert(begin() + position, first, last);
483 }
484
485 //*************************************************************************
490 //*************************************************************************
491 template <typename TIterator>
492 iterator insert(const_iterator position, TIterator first, const TIterator last)
493 {
494 ETL_ASSERT_CHECK_EXTRA(cbegin() <= position && position < cend(), ETL_ERROR(array_out_of_range));
495
496 iterator p = to_iterator(position);
497 iterator result(p);
498
499 size_t source_size = etl::distance(first, last);
500 size_t destination_space = etl::distance(position, cend());
501
502 // Do we need to move anything?
503 if (source_size < destination_space)
504 {
505 size_t length = SIZE - (etl::distance(begin(), p) + source_size);
506 etl::move_backward(p, p + length, end());
507 }
508
509 // Copy from the range.
510 etl::copy_s(first, last, p, end());
511
512 return result;
513 }
514
515 //*************************************************************************
519 //*************************************************************************
520 inline iterator erase_at(size_t position)
521 {
522 ETL_ASSERT_CHECK_EXTRA(position < SIZE, ETL_ERROR(array_out_of_range));
523
524 return erase(begin() + position);
525 }
526
527 //*************************************************************************
531 //*************************************************************************
532 iterator erase(const_iterator position)
533 {
534 ETL_ASSERT_CHECK_EXTRA(cbegin() <= position && position < cend(), ETL_ERROR(array_out_of_range));
535
536 iterator p = to_iterator(position);
537 etl::move(p + 1, end(), p);
538
539 return p;
540 }
541
542 //*************************************************************************
547 //*************************************************************************
548 iterator erase_range(size_t first, size_t last)
549 {
550 ETL_ASSERT_CHECK_EXTRA(first <= last && last <= SIZE, ETL_ERROR(array_out_of_range));
551
552 return erase(begin() + first, begin() + last);
553 }
554
555 //*************************************************************************
560 //*************************************************************************
561 iterator erase(const_iterator first, const_iterator last)
562 {
563 ETL_ASSERT_CHECK_EXTRA(cbegin() <= first && first <= last && last <= cend(), ETL_ERROR(array_out_of_range));
564
565 iterator p = to_iterator(first);
566 etl::move(last, cend(), p);
567 return p;
568 }
569
570 //*************************************************************************
574 //*************************************************************************
575 inline iterator erase_at(size_t position, parameter_t value)
576 {
577 ETL_ASSERT_CHECK_EXTRA(position < SIZE, ETL_ERROR(array_out_of_range));
578
579 return erase(begin() + position, value);
580 }
581
582 //*************************************************************************
586 //*************************************************************************
587 iterator erase(const_iterator position, parameter_t value)
588 {
589 ETL_ASSERT_CHECK_EXTRA(cbegin() <= position && position < cend(), ETL_ERROR(array_out_of_range));
590
591 iterator p = to_iterator(position);
592
593 etl::move(p + 1, end(), p);
594 back() = value;
595
596 return p;
597 }
598
599 //*************************************************************************
604 //*************************************************************************
605 iterator erase_range(size_t first, size_t last, parameter_t value)
606 {
607 ETL_ASSERT_CHECK_EXTRA(first <= last && last <= SIZE, ETL_ERROR(array_out_of_range));
608
609 return erase(begin() + first, begin() + last, value);
610 }
611
612 //*************************************************************************
617 //*************************************************************************
618 iterator erase(const_iterator first, const_iterator last, parameter_t value)
619 {
620 ETL_ASSERT_CHECK_EXTRA(cbegin() <= first && first <= last && last <= cend(), ETL_ERROR(array_out_of_range));
621
622 iterator p = to_iterator(first);
623
624 p = etl::move(last, cend(), p);
625 etl::fill(p, end(), value);
626
627 return to_iterator(first);
628 }
629
631 T _buffer[SIZE];
632
633 private:
634
635 //*************************************************************************
637 //*************************************************************************
638 iterator to_iterator(const_iterator itr) const
639 {
640 return const_cast<iterator>(itr);
641 }
642 };
643
644 template <typename T, size_t SIZE_>
645 ETL_CONSTANT size_t array<T, SIZE_>::SIZE;
646
647 //***************************************************************************
651 //***************************************************************************
652 template <typename T>
653 class array<T, 0>
654 {
655 private:
656
657 typedef typename etl::parameter_type<T>::type parameter_t;
658
659 public:
660
661 static ETL_CONSTANT size_t SIZE = 0;
662
663 typedef T value_type;
664 typedef size_t size_type;
665 typedef ptrdiff_t difference_type;
666 typedef T& reference;
667 typedef const T& const_reference;
668 typedef T* pointer;
669 typedef const T* const_pointer;
670 typedef T* iterator;
671 typedef const T* const_iterator;
672 typedef ETL_OR_STD::reverse_iterator<iterator> reverse_iterator;
673 typedef ETL_OR_STD::reverse_iterator<const_iterator> const_reverse_iterator;
674
675 //*************************************************************************
676 // Element access
677 //*************************************************************************
678
679 //*************************************************************************
682 //*************************************************************************
683 ETL_NODISCARD
684 ETL_CONSTEXPR14
685 reference at(size_t) ETL_NOEXCEPT
686 {
687 return *data();
688 }
689
690 //*************************************************************************
693 //*************************************************************************
694 ETL_NODISCARD
695 ETL_CONSTEXPR14
696 const_reference at(size_t) const ETL_NOEXCEPT
697 {
698 return *data();
699 }
700
701 //*************************************************************************
705 //*************************************************************************
706 ETL_NODISCARD
707 ETL_CONSTEXPR14
708 reference operator[](size_t) ETL_NOEXCEPT
709 {
710 return *data();
711 }
712
713 //*************************************************************************
717 //*************************************************************************
718 ETL_NODISCARD
719 ETL_CONSTEXPR const_reference operator[](size_t) const ETL_NOEXCEPT
720 {
721 return *data();
722 }
723
724 //*************************************************************************
726 //*************************************************************************
727 ETL_NODISCARD
728 ETL_CONSTEXPR14
729 reference front() ETL_NOEXCEPT
730 {
731 return *data();
732 }
733
734 //*************************************************************************
736 //*************************************************************************
737 ETL_NODISCARD
738 ETL_CONSTEXPR const_reference front() const ETL_NOEXCEPT
739 {
740 return *data();
741 }
742
743 //*************************************************************************
745 //*************************************************************************
746 ETL_NODISCARD
747 ETL_CONSTEXPR14
748 reference back() ETL_NOEXCEPT
749 {
750 return *data();
751 }
752
753 //*************************************************************************
755 //*************************************************************************
756 ETL_NODISCARD
757 ETL_CONSTEXPR const_reference back() const
758 {
759 return *data();
760 }
761
762 //*************************************************************************
764 //*************************************************************************
765 ETL_NODISCARD
766 ETL_CONSTEXPR14
767 pointer data() ETL_NOEXCEPT
768 {
769 return (T*)0;
770 }
771
772 //*************************************************************************
774 //*************************************************************************
775 ETL_NODISCARD
776 ETL_CONSTEXPR const_pointer data() const ETL_NOEXCEPT
777 {
778 return (const T*)0;
779 }
780
781 //*************************************************************************
782 // Iterators
783 //*************************************************************************
784
785 //*************************************************************************
787 //*************************************************************************
788 ETL_NODISCARD
789 ETL_CONSTEXPR14
790 iterator begin() ETL_NOEXCEPT
791 {
792 return iterator();
793 }
794
795 //*************************************************************************
797 //*************************************************************************
798 ETL_NODISCARD
799 ETL_CONSTEXPR const_iterator begin() const ETL_NOEXCEPT
800 {
801 return const_iterator();
802 }
803
804 //*************************************************************************
806 //*************************************************************************
807 ETL_NODISCARD
808 ETL_CONSTEXPR const_iterator cbegin() const ETL_NOEXCEPT
809 {
810 return const_iterator();
811 }
812
813 //*************************************************************************
815 //*************************************************************************
816 ETL_NODISCARD
817 ETL_CONSTEXPR14
818 iterator end() ETL_NOEXCEPT
819 {
820 return iterator();
821 }
822
823 //*************************************************************************
825 //*************************************************************************
826 ETL_NODISCARD
827 ETL_CONSTEXPR const_iterator end() const ETL_NOEXCEPT
828 {
829 return const_iterator();
830 }
831
832 //*************************************************************************
833 // Returns a const iterator to the end of the array.
834 //*************************************************************************
835 ETL_NODISCARD
836 ETL_CONSTEXPR const_iterator cend() const ETL_NOEXCEPT
837 {
838 return const_iterator();
839 }
840
841 //*************************************************************************
842 // Returns an reverse iterator to the reverse beginning of the array.
843 //*************************************************************************
844 ETL_NODISCARD
845 ETL_CONSTEXPR14
846 reverse_iterator rbegin() ETL_NOEXCEPT
847 {
848 return reverse_iterator(end());
849 }
850
851 //*************************************************************************
853 //*************************************************************************
854 ETL_NODISCARD
855 ETL_CONSTEXPR const_reverse_iterator rbegin() const ETL_NOEXCEPT
856 {
857 return const_reverse_iterator(end());
858 }
859
860 //*************************************************************************
862 //*************************************************************************
863 ETL_NODISCARD
864 ETL_CONSTEXPR const_reverse_iterator crbegin() const ETL_NOEXCEPT
865 {
866 return const_reverse_iterator(end());
867 }
868
869 //*************************************************************************
871 //*************************************************************************
872 ETL_NODISCARD
873 ETL_CONSTEXPR14
874 reverse_iterator rend() ETL_NOEXCEPT
875 {
876 return reverse_iterator(begin());
877 }
878
879 //*************************************************************************
881 //*************************************************************************
882 ETL_NODISCARD
883 ETL_CONSTEXPR const_reverse_iterator rend() const ETL_NOEXCEPT
884 {
885 return const_reverse_iterator(begin());
886 }
887
888 //*************************************************************************
890 //*************************************************************************
891 ETL_NODISCARD
892 ETL_CONSTEXPR const_reverse_iterator crend() const ETL_NOEXCEPT
893 {
894 return const_reverse_iterator(begin());
895 }
896
897 //*************************************************************************
898 // Capacity
899 //*************************************************************************
900
901 //*************************************************************************
903 //*************************************************************************
904 ETL_NODISCARD
905 ETL_CONSTEXPR bool empty() const ETL_NOEXCEPT
906 {
907 return true;
908 }
909
910 //*************************************************************************
912 //*************************************************************************
913 ETL_NODISCARD
914 ETL_CONSTEXPR size_t size() const ETL_NOEXCEPT
915 {
916 return 0;
917 }
918
919 //*************************************************************************
921 //*************************************************************************
922 ETL_NODISCARD
923 ETL_CONSTEXPR size_t max_size() const ETL_NOEXCEPT
924 {
925 return 0;
926 }
927
928 //*************************************************************************
929 // Operations
930 //*************************************************************************
931
932 //*************************************************************************
935 //*************************************************************************
936 ETL_CONSTEXPR14 void fill(parameter_t) ETL_NOEXCEPT
937 {
938 }
939
940 //*************************************************************************
943 //*************************************************************************
944 ETL_CONSTEXPR14 void swap(array&) ETL_NOEXCEPT
945 {
946 }
947
948 //*************************************************************************
954 //*************************************************************************
955 template <typename TIterator>
956 iterator assign(TIterator, const TIterator) ETL_NOEXCEPT
957 {
958 return iterator();
959 }
960
961 //*************************************************************************
967 //*************************************************************************
968 template <typename TIterator>
969 iterator assign(TIterator, const TIterator, parameter_t) ETL_NOEXCEPT
970 {
971 return iterator();
972 }
973
974 //*************************************************************************
978 //*************************************************************************
979 inline iterator insert_at(size_t, parameter_t) ETL_NOEXCEPT
980 {
981 return iterator();
982 }
983
984 //*************************************************************************
988 //*************************************************************************
989 iterator insert(const_iterator, parameter_t) ETL_NOEXCEPT
990 {
991 return iterator();
992 }
993
994 //*************************************************************************
999 //*************************************************************************
1000 template <typename TIterator>
1001 inline iterator insert_at(size_t, TIterator, const TIterator) ETL_NOEXCEPT
1002 {
1003 return iterator();
1004 }
1005
1006 //*************************************************************************
1011 //*************************************************************************
1012 template <typename TIterator>
1013 iterator insert(const_iterator, TIterator, const TIterator) ETL_NOEXCEPT
1014 {
1015 return iterator();
1016 }
1017
1018 //*************************************************************************
1022 //*************************************************************************
1023 inline iterator erase_at(size_t) ETL_NOEXCEPT
1024 {
1025 return iterator();
1026 }
1027
1028 //*************************************************************************
1032 //*************************************************************************
1033 iterator erase(const_iterator) ETL_NOEXCEPT
1034 {
1035 return iterator();
1036 }
1037
1038 //*************************************************************************
1043 //*************************************************************************
1044 iterator erase_range(size_t, size_t) ETL_NOEXCEPT
1045 {
1046 return iterator();
1047 }
1048
1049 //*************************************************************************
1054 //*************************************************************************
1055 iterator erase(const_iterator, const_iterator) ETL_NOEXCEPT
1056 {
1057 return iterator();
1058 }
1059
1060 //*************************************************************************
1064 //*************************************************************************
1065 inline iterator erase_at(size_t, parameter_t) ETL_NOEXCEPT
1066 {
1067 return iterator();
1068 }
1069
1070 //*************************************************************************
1074 //*************************************************************************
1075 iterator erase(const_iterator, parameter_t) ETL_NOEXCEPT
1076 {
1077 return iterator();
1078 }
1079
1080 //*************************************************************************
1085 //*************************************************************************
1086 iterator erase_range(size_t, size_t, parameter_t) ETL_NOEXCEPT
1087 {
1088 return iterator();
1089 }
1090
1091 //*************************************************************************
1095 //*************************************************************************
1096 iterator erase(const_iterator, const_iterator, parameter_t) ETL_NOEXCEPT
1097 {
1098 return iterator();
1099 }
1100 };
1101
1102 //*************************************************************************
1104 //*************************************************************************
1105#if ETL_USING_CPP17
1106 template <typename... T>
1107 array(T...) -> array<typename etl::common_type<T...>::type, sizeof...(T)>;
1108#endif
1109
1110 //*************************************************************************
1112 //*************************************************************************
1113#if ETL_HAS_INITIALIZER_LIST
1114 template <typename T, typename... TValues>
1115 constexpr auto make_array(TValues&&... values) ETL_NOEXCEPT -> etl::array<T, sizeof...(TValues)>
1116 {
1117 return { etl::forward<T>(values)... };
1118 }
1119#endif
1120
1121 //*************************************************************************
1125 //*************************************************************************
1126 template <typename T, const size_t SIZE>
1128 {
1129 lhs.swap(rhs);
1130 }
1131
1132 //*************************************************************************
1137 //*************************************************************************
1138 template <typename T, size_t SIZE>
1140 {
1141 return etl::equal(lhs.cbegin(), lhs.cend(), rhs.cbegin());
1142 }
1143
1144 //*************************************************************************
1149 //*************************************************************************
1150 template <typename T, size_t SIZE>
1152 {
1153 return !(lhs == rhs);
1154 }
1155
1156 //*************************************************************************
1161 //*************************************************************************
1162 template <typename T, size_t SIZE>
1164 {
1165 return etl::lexicographical_compare(lhs.cbegin(),
1166 lhs.cend(),
1167 rhs.cbegin(),
1168 rhs.cend());
1169 }
1170
1171 //*************************************************************************
1176 //*************************************************************************
1177 template <typename T, size_t SIZE>
1179 {
1180 return !(lhs > rhs);
1181 }
1182
1183 //*************************************************************************
1188 template <typename T, size_t SIZE>
1189 //*************************************************************************
1191 {
1192 return (rhs < lhs);
1193 }
1194
1195 //*************************************************************************
1200 //*************************************************************************
1201 template <typename T, size_t SIZE>
1203 {
1204 return !(lhs < rhs);
1205 }
1206
1207 //*************************************************************************
1214 //*************************************************************************
1215 template <size_t Index, typename T, size_t Size>
1216 inline T& get(array<T, Size>& a)
1217 {
1218 ETL_STATIC_ASSERT(Index < Size, "Index out of bounds");
1219 return a[Index];
1220 }
1221
1222 //*************************************************************************
1229 //*************************************************************************
1230 template <size_t Index, typename T, size_t Size>
1231 inline const T& get(const array<T, Size>& a)
1232 {
1233 ETL_STATIC_ASSERT(Index < Size, "Index out of bounds");
1234 return a[Index];
1235 }
1236}
1237
1238#endif
ETL_CONSTEXPR14 etl::enable_if< etl::is_random_iterator< TInputIterator >::value &&etl::is_random_iterator< TOutputIterator >::value, TOutputIterator >::type copy_s(TInputIterator i_begin, TInputIterator i_end, TOutputIterator o_begin, TOutputIterator o_end)
Definition algorithm.h:2368
ETL_NODISCARD ETL_CONSTEXPR14 reference at(size_t) ETL_NOEXCEPT
Definition array.h:685
ETL_NODISCARD ETL_CONSTEXPR14 reference operator[](size_t i) ETL_NOEXCEPT_EXPR(ETL_NOT_USING_EXCEPTIONS||ETL_NOT_CHECKING_INDEX_OPERATOR)
Definition array.h:146
ETL_NODISCARD ETL_CONSTEXPR const_reverse_iterator rend() const ETL_NOEXCEPT
Returns a const reverse iterator to the end of the array.
Definition array.h:883
ETL_NODISCARD ETL_CONSTEXPR14 reference operator[](size_t) ETL_NOEXCEPT
Definition array.h:708
iterator erase(const_iterator first, const_iterator last)
Definition array.h:561
ETL_NODISCARD ETL_CONSTEXPR14 reverse_iterator rend() ETL_NOEXCEPT
Returns a reverse iterator to the end of the array.
Definition array.h:329
iterator erase_at(size_t) ETL_NOEXCEPT
Definition array.h:1023
ETL_NODISCARD ETL_CONSTEXPR const_reference front() const ETL_NOEXCEPT
Returns a const reference to the first element.
Definition array.h:738
ETL_NODISCARD ETL_CONSTEXPR const_reference operator[](size_t) const ETL_NOEXCEPT
Definition array.h:719
iterator assign(TIterator, const TIterator) ETL_NOEXCEPT
Definition array.h:956
ETL_NODISCARD ETL_CONSTEXPR14 reference front() ETL_NOEXCEPT
Returns a reference to the first element.
Definition array.h:176
ETL_NODISCARD ETL_CONSTEXPR const_pointer data() const ETL_NOEXCEPT
Returns a const pointer to the first element of the internal buffer.
Definition array.h:776
ETL_NODISCARD ETL_CONSTEXPR const_reverse_iterator crbegin() const ETL_NOEXCEPT
Returns a const reverse iterator to the reverse beginning of the array.
Definition array.h:319
ETL_NODISCARD ETL_CONSTEXPR const_reverse_iterator rbegin() const ETL_NOEXCEPT
Returns a const reverse iterator to the reverse beginning of the array.
Definition array.h:310
ETL_NODISCARD ETL_CONSTEXPR14 iterator end() ETL_NOEXCEPT
Returns an iterator to the end of the array.
Definition array.h:818
ETL_NODISCARD ETL_CONSTEXPR14 iterator begin() ETL_NOEXCEPT
Returns an iterator to the beginning of the array.
Definition array.h:245
delegate_type _buffer[SIZE]
Definition array.h:631
ETL_NODISCARD ETL_CONSTEXPR const_iterator begin() const ETL_NOEXCEPT
Returns a const iterator to the beginning of the array.
Definition array.h:254
iterator insert_at(size_t, parameter_t) ETL_NOEXCEPT
Definition array.h:979
ETL_NODISCARD ETL_CONSTEXPR const_reverse_iterator crend() const ETL_NOEXCEPT
Returns a const reverse iterator to the end of the array.
Definition array.h:892
iterator erase_range(size_t, size_t) ETL_NOEXCEPT
Definition array.h:1044
ETL_NODISCARD ETL_CONSTEXPR const_reference operator[](size_t i) const ETL_NOEXCEPT_EXPR(ETL_NOT_USING_EXCEPTIONS||ETL_NOT_CHECKING_INDEX_OPERATOR)
Definition array.h:159
ETL_NODISCARD ETL_CONSTEXPR14 pointer data() ETL_NOEXCEPT
Returns a pointer to the first element of the internal buffer.
Definition array.h:222
iterator erase_range(size_t, size_t, parameter_t) ETL_NOEXCEPT
Definition array.h:1086
iterator erase_range(size_t first, size_t last)
Definition array.h:548
ETL_CONSTEXPR14 void fill(parameter_t) ETL_NOEXCEPT
Definition array.h:936
ETL_NODISCARD ETL_CONSTEXPR const_reference back() const ETL_NOEXCEPT
Returns a const reference to the last element.
Definition array.h:210
ETL_NODISCARD ETL_CONSTEXPR14 reference back() ETL_NOEXCEPT
Returns a reference to the last element.
Definition array.h:199
ETL_NODISCARD ETL_CONSTEXPR14 iterator begin() ETL_NOEXCEPT
Returns an iterator to the beginning of the array.
Definition array.h:790
ETL_CONSTEXPR14 void fill(parameter_t value)
Definition array.h:391
iterator insert_at(size_t, TIterator, const TIterator) ETL_NOEXCEPT
Definition array.h:1001
iterator erase(const_iterator) ETL_NOEXCEPT
Definition array.h:1033
iterator insert_at(size_t position, parameter_t value)
Definition array.h:447
iterator assign(TIterator, const TIterator, parameter_t) ETL_NOEXCEPT
Definition array.h:969
iterator erase_range(size_t first, size_t last, parameter_t value)
Definition array.h:605
ETL_NODISCARD ETL_CONSTEXPR14 const_reference at(size_t i) const ETL_NOEXCEPT_EXPR(ETL_NOT_USING_EXCEPTIONS)
Definition array.h:132
ETL_NODISCARD ETL_CONSTEXPR const_iterator end() const ETL_NOEXCEPT
Returns a const iterator to the end of the array.
Definition array.h:282
iterator insert(const_iterator, parameter_t) ETL_NOEXCEPT
Definition array.h:989
ETL_NODISCARD ETL_CONSTEXPR size_t max_size() const ETL_NOEXCEPT
Returns the maximum possible size of the array.
Definition array.h:923
ETL_NODISCARD ETL_CONSTEXPR const_iterator end() const ETL_NOEXCEPT
Returns a const iterator to the end of the array.
Definition array.h:827
ETL_NODISCARD ETL_CONSTEXPR size_t size() const ETL_NOEXCEPT
Returns the size of the array.
Definition array.h:914
ETL_NODISCARD ETL_CONSTEXPR const_reverse_iterator crbegin() const ETL_NOEXCEPT
Returns a const reverse iterator to the reverse beginning of the array.
Definition array.h:864
ETL_NODISCARD ETL_CONSTEXPR14 const_reference at(size_t) const ETL_NOEXCEPT
Definition array.h:696
ETL_CONSTEXPR14 void swap(array &) ETL_NOEXCEPT
Definition array.h:944
iterator erase_at(size_t position)
Definition array.h:520
ETL_NODISCARD ETL_CONSTEXPR const_reference back() const
Returns a const reference to the last element.
Definition array.h:757
iterator erase(const_iterator first, const_iterator last, parameter_t value)
Definition array.h:618
iterator erase(const_iterator position, parameter_t value)
Definition array.h:587
iterator insert(const_iterator, TIterator, const TIterator) ETL_NOEXCEPT
Definition array.h:1013
iterator erase(const_iterator, parameter_t) ETL_NOEXCEPT
Definition array.h:1075
ETL_NODISCARD ETL_CONSTEXPR14 pointer data() ETL_NOEXCEPT
Returns a pointer to the first element of the internal buffer.
Definition array.h:767
ETL_NODISCARD ETL_CONSTEXPR const_iterator cbegin() const ETL_NOEXCEPT
Returns a const iterator to the beginning of the array.
Definition array.h:808
iterator erase(const_iterator, const_iterator) ETL_NOEXCEPT
Definition array.h:1055
ETL_NODISCARD ETL_CONSTEXPR14 iterator end() ETL_NOEXCEPT
Returns an iterator to the end of the array.
Definition array.h:273
iterator insert(const_iterator position, parameter_t value)
Definition array.h:459
ETL_NODISCARD ETL_CONSTEXPR const_reverse_iterator crend() const ETL_NOEXCEPT
Returns a const reverse iterator to the end of the array.
Definition array.h:347
ETL_NODISCARD ETL_CONSTEXPR const_iterator begin() const ETL_NOEXCEPT
Returns a const iterator to the beginning of the array.
Definition array.h:799
ETL_NODISCARD ETL_CONSTEXPR bool empty() const ETL_NOEXCEPT
Returns true if the array size is zero.
Definition array.h:360
iterator erase_at(size_t, parameter_t) ETL_NOEXCEPT
Definition array.h:1065
ETL_NODISCARD ETL_CONSTEXPR const_pointer data() const ETL_NOEXCEPT
Returns a const pointer to the first element of the internal buffer.
Definition array.h:231
ETL_NODISCARD ETL_CONSTEXPR size_t size() const ETL_NOEXCEPT
Returns the size of the array.
Definition array.h:369
ETL_NODISCARD ETL_CONSTEXPR14 reference at(size_t i) ETL_NOEXCEPT_EXPR(ETL_NOT_USING_EXCEPTIONS)
Definition array.h:119
ETL_CONSTEXPR14 void swap(array &other) ETL_NOEXCEPT_FROM(ETL_OR_STD
Definition array.h:400
iterator insert(const_iterator position, TIterator first, const TIterator last)
Definition array.h:492
iterator assign(TIterator first, const TIterator last)
Definition array.h:418
ETL_NODISCARD ETL_CONSTEXPR const_reverse_iterator rbegin() const ETL_NOEXCEPT
Returns a const reverse iterator to the reverse beginning of the array.
Definition array.h:855
ETL_NODISCARD ETL_CONSTEXPR14 reference front() ETL_NOEXCEPT
Returns a reference to the first element.
Definition array.h:729
ETL_NODISCARD ETL_CONSTEXPR const_iterator cbegin() const ETL_NOEXCEPT
Returns a const iterator to the beginning of the array.
Definition array.h:263
iterator erase(const_iterator position)
Definition array.h:532
ETL_NODISCARD ETL_CONSTEXPR14 reference back() ETL_NOEXCEPT
Returns a reference to the last element.
Definition array.h:748
iterator assign(TIterator first, const TIterator last, parameter_t value)
Definition array.h:431
iterator erase(const_iterator, const_iterator, parameter_t) ETL_NOEXCEPT
Definition array.h:1096
ETL_NODISCARD ETL_CONSTEXPR14 reverse_iterator rend() ETL_NOEXCEPT
Returns a reverse iterator to the end of the array.
Definition array.h:874
iterator erase_at(size_t position, parameter_t value)
Definition array.h:575
ETL_NODISCARD ETL_CONSTEXPR const_reference front() const ETL_NOEXCEPT
Returns a const reference to the first element.
Definition array.h:187
iterator insert_at(size_t position, TIterator first, const TIterator last)
Definition array.h:478
ETL_NODISCARD ETL_CONSTEXPR const_reverse_iterator rend() const ETL_NOEXCEPT
Returns a const reverse iterator to the end of the array.
Definition array.h:338
ETL_NODISCARD ETL_CONSTEXPR bool empty() const ETL_NOEXCEPT
Returns true if the array size is zero.
Definition array.h:905
ETL_NODISCARD ETL_CONSTEXPR size_t max_size() const ETL_NOEXCEPT
Returns the maximum possible size of the array.
Definition array.h:378
Definition array.h:88
Definition array.h:73
#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
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
bool operator>(const etl::array< T, SIZE > &lhs, const etl::array< T, SIZE > &rhs)
Definition array.h:1190
bool operator>=(const etl::array< T, SIZE > &lhs, const etl::array< T, SIZE > &rhs)
Definition array.h:1202
bool operator!=(const etl::array< T, SIZE > &lhs, const etl::array< T, SIZE > &rhs)
Definition array.h:1151
bool operator==(const etl::array< T, SIZE > &lhs, const etl::array< T, SIZE > &rhs)
Definition array.h:1139
T & get(array< T, Size > &a)
Definition array.h:1216
ETL_CONSTEXPR TContainer::const_iterator cend(const TContainer &container)
Definition iterator.h:1012
bool operator<(const etl::array< T, SIZE > &lhs, const etl::array< T, SIZE > &rhs)
Definition array.h:1163
bool operator<=(const etl::array< T, SIZE > &lhs, const etl::array< T, SIZE > &rhs)
Definition array.h:1178
etl::conditional< etl::is_fundamental< T >::value||etl::is_pointer< T >::value, T, constT & >::type type
By default fundamental and pointer types are passed by value.
Definition parameter_type.h:48