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 "error_handler.h"
37#include "exception.h"
38#include "iterator.h"
39#include "parameter_type.h"
40#include "static_assert.h"
41#include "type_traits.h"
42
43#include <stddef.h>
44
48
49namespace etl
50{
51 //***************************************************************************
54 //***************************************************************************
55 class array_exception : public exception
56 {
57 public:
58
59 array_exception(string_type reason_, string_type file_name_, numeric_type line_number_)
60 : exception(reason_, file_name_, line_number_)
61 {
62 }
63 };
64
65 //***************************************************************************
68 //***************************************************************************
69 class array_out_of_range : public array_exception
70 {
71 public:
72
73 array_out_of_range(string_type file_name_, numeric_type line_number_)
74 : array_exception("array:range", file_name_, line_number_)
75 {
76 }
77 };
78
79 //***************************************************************************
82 //***************************************************************************
83 template <typename T, size_t SIZE_>
84 class array
85 {
86 private:
87
88 typedef typename etl::parameter_type<T>::type parameter_t;
89
90 public:
91
92 static ETL_CONSTANT size_t SIZE = SIZE_;
93
94 typedef T value_type;
95 typedef size_t size_type;
96 typedef ptrdiff_t difference_type;
97 typedef T& reference;
98 typedef const T& const_reference;
99 typedef T* pointer;
100 typedef const T* const_pointer;
101 typedef T* iterator;
102 typedef const T* const_iterator;
103 typedef ETL_OR_STD::reverse_iterator<iterator> reverse_iterator;
104 typedef ETL_OR_STD::reverse_iterator<const_iterator> const_reverse_iterator;
105
106 //*************************************************************************
107 // Element access
108 //*************************************************************************
109
110 //*************************************************************************
113 //*************************************************************************
114 ETL_NODISCARD ETL_CONSTEXPR14 reference at(size_t i) ETL_NOEXCEPT_EXPR(ETL_NOT_USING_EXCEPTIONS)
115 {
116 ETL_ASSERT(i < SIZE, ETL_ERROR(array_out_of_range));
117
118 return _buffer[i];
119 }
120
121 //*************************************************************************
124 //*************************************************************************
125 ETL_NODISCARD ETL_CONSTEXPR14 const_reference at(size_t i) const ETL_NOEXCEPT_EXPR(ETL_NOT_USING_EXCEPTIONS)
126 {
127 ETL_ASSERT(i < SIZE, ETL_ERROR(array_out_of_range));
128
129 return _buffer[i];
130 }
131
132 //*************************************************************************
136 //*************************************************************************
137 ETL_NODISCARD ETL_CONSTEXPR14 reference operator[](size_t i) ETL_NOEXCEPT_EXPR(ETL_NOT_USING_EXCEPTIONS || ETL_NOT_CHECKING_INDEX_OPERATOR)
138 {
139 ETL_ASSERT_CHECK_INDEX_OPERATOR(i < SIZE, ETL_ERROR(array_out_of_range));
140
141 return _buffer[i];
142 }
143
144 //*************************************************************************
148 //*************************************************************************
149 ETL_NODISCARD ETL_CONSTEXPR const_reference operator[](size_t i) const ETL_NOEXCEPT_EXPR(ETL_NOT_USING_EXCEPTIONS || ETL_NOT_CHECKING_INDEX_OPERATOR)
150 {
151 // Throwing from c++11 constexpr requires special syntax
152#if ETL_USING_CPP11 && ETL_NOT_USING_CPP14 && ETL_USING_EXCEPTIONS && ETL_CHECKING_INDEX_OPERATOR
153 return i < SIZE ? _buffer[i] : throw(ETL_ERROR(array_out_of_range));
154#else
155 ETL_ASSERT_CHECK_INDEX_OPERATOR(i < SIZE, ETL_ERROR(array_out_of_range));
156
157 return _buffer[i];
158#endif
159 }
160
161 //*************************************************************************
163 //*************************************************************************
164 ETL_NODISCARD ETL_CONSTEXPR14 reference front() ETL_NOEXCEPT
165 {
166 ETL_STATIC_ASSERT(SIZE > 0, "Array is empty.");
167
168 return _buffer[0];
169 }
170
171 //*************************************************************************
173 //*************************************************************************
174 ETL_NODISCARD ETL_CONSTEXPR const_reference front() const ETL_NOEXCEPT
175 {
176 ETL_STATIC_ASSERT(SIZE > 0, "Array is empty.");
177
178 return _buffer[0];
179 }
180
181 //*************************************************************************
183 //*************************************************************************
184 ETL_NODISCARD ETL_CONSTEXPR14 reference back() ETL_NOEXCEPT
185 {
186 ETL_STATIC_ASSERT(SIZE > 0, "Array is empty.");
187
188 return _buffer[SIZE - 1];
189 }
190
191 //*************************************************************************
193 //*************************************************************************
194 ETL_NODISCARD ETL_CONSTEXPR const_reference back() const ETL_NOEXCEPT
195 {
196 ETL_STATIC_ASSERT(SIZE > 0, "Array is empty.");
197
198 return _buffer[SIZE - 1];
199 }
200
201 //*************************************************************************
203 //*************************************************************************
204 ETL_NODISCARD ETL_CONSTEXPR14 pointer data() ETL_NOEXCEPT
205 {
206 return _buffer;
207 }
208
209 //*************************************************************************
211 //*************************************************************************
212 ETL_NODISCARD ETL_CONSTEXPR const_pointer data() const ETL_NOEXCEPT
213 {
214 return _buffer;
215 }
216
217 //*************************************************************************
218 // Iterators
219 //*************************************************************************
220
221 //*************************************************************************
223 //*************************************************************************
224 ETL_NODISCARD ETL_CONSTEXPR14 iterator begin() ETL_NOEXCEPT
225 {
226 return _buffer;
227 }
228
229 //*************************************************************************
231 //*************************************************************************
232 ETL_NODISCARD ETL_CONSTEXPR const_iterator begin() const ETL_NOEXCEPT
233 {
234 return _buffer;
235 }
236
237 //*************************************************************************
239 //*************************************************************************
240 ETL_NODISCARD ETL_CONSTEXPR const_iterator cbegin() const ETL_NOEXCEPT
241 {
242 return begin();
243 }
244
245 //*************************************************************************
247 //*************************************************************************
248 ETL_NODISCARD ETL_CONSTEXPR14 iterator end() ETL_NOEXCEPT
249 {
250 return _buffer + SIZE;
251 }
252
253 //*************************************************************************
255 //*************************************************************************
256 ETL_NODISCARD ETL_CONSTEXPR const_iterator end() const ETL_NOEXCEPT
257 {
258 return _buffer + SIZE;
259 }
260
261 //*************************************************************************
262 // Returns a const iterator to the end of the array.
263 //*************************************************************************
264 ETL_NODISCARD ETL_CONSTEXPR const_iterator cend() const ETL_NOEXCEPT
265 {
266 return _buffer + SIZE;
267 }
268
269 //*************************************************************************
270 // Returns an reverse iterator to the reverse beginning of the array.
271 //*************************************************************************
272 ETL_NODISCARD ETL_CONSTEXPR14 reverse_iterator rbegin() ETL_NOEXCEPT
273 {
274 return reverse_iterator(end());
275 }
276
277 //*************************************************************************
279 //*************************************************************************
280 ETL_NODISCARD ETL_CONSTEXPR const_reverse_iterator rbegin() const ETL_NOEXCEPT
281 {
282 return const_reverse_iterator(end());
283 }
284
285 //*************************************************************************
287 //*************************************************************************
288 ETL_NODISCARD ETL_CONSTEXPR const_reverse_iterator crbegin() const ETL_NOEXCEPT
289 {
290 return const_reverse_iterator(end());
291 }
292
293 //*************************************************************************
295 //*************************************************************************
296 ETL_NODISCARD ETL_CONSTEXPR14 reverse_iterator rend() ETL_NOEXCEPT
297 {
298 return reverse_iterator(begin());
299 }
300
301 //*************************************************************************
303 //*************************************************************************
304 ETL_NODISCARD ETL_CONSTEXPR const_reverse_iterator rend() const ETL_NOEXCEPT
305 {
306 return const_reverse_iterator(begin());
307 }
308
309 //*************************************************************************
311 //*************************************************************************
312 ETL_NODISCARD ETL_CONSTEXPR const_reverse_iterator crend() const ETL_NOEXCEPT
313 {
314 return const_reverse_iterator(begin());
315 }
316
317 //*************************************************************************
318 // Capacity
319 //*************************************************************************
320
321 //*************************************************************************
323 //*************************************************************************
324 ETL_NODISCARD ETL_CONSTEXPR bool empty() const ETL_NOEXCEPT
325 {
326 return (SIZE == 0);
327 }
328
329 //*************************************************************************
331 //*************************************************************************
332 ETL_NODISCARD ETL_CONSTEXPR size_t size() const ETL_NOEXCEPT
333 {
334 return SIZE;
335 }
336
337 //*************************************************************************
339 //*************************************************************************
340 ETL_NODISCARD ETL_CONSTEXPR size_t max_size() const ETL_NOEXCEPT
341 {
342 return SIZE;
343 }
344
345 //*************************************************************************
346 // Operations
347 //*************************************************************************
348
349 //*************************************************************************
352 //*************************************************************************
353 ETL_CONSTEXPR14 void fill(parameter_t value)
354 {
355 etl::fill(_buffer, _buffer + SIZE, value);
356 }
357
358 //*************************************************************************
361 //*************************************************************************
362 ETL_CONSTEXPR14 void swap(array& other) ETL_NOEXCEPT_FROM(ETL_OR_STD::swap(etl::declval<T&>(), etl::declval<T&>()))
363 {
364 using ETL_OR_STD::swap; // Allow ADL
365
366 for (size_t i = 0UL; i < SIZE; ++i)
367 {
368 swap(_buffer[i], other._buffer[i]);
369 }
370 }
371
372 //*************************************************************************
379 //*************************************************************************
380 template <typename TIterator>
381 iterator assign(TIterator first, const TIterator last)
382 {
383 return etl::copy_s(first, last, begin(), end());
384 }
385
386 //*************************************************************************
393 //*************************************************************************
394 template <typename TIterator>
395 iterator assign(TIterator first, const TIterator last, parameter_t value)
396 {
397 // Copy from the range.
398 iterator p = etl::copy_s(first, last, begin(), end());
399
400 // Initialise any that are left.
401 etl::fill(p, end(), value);
402
403 return p;
404 }
405
406 //*************************************************************************
410 //*************************************************************************
411 inline iterator insert_at(size_t position, parameter_t value)
412 {
413 ETL_ASSERT_CHECK_EXTRA(position < SIZE, ETL_ERROR(array_out_of_range));
414
415 return insert(begin() + position, value);
416 }
417
418 //*************************************************************************
422 //*************************************************************************
423 iterator insert(const_iterator position, parameter_t value)
424 {
425 ETL_ASSERT_CHECK_EXTRA(cbegin() <= position && position < cend(), ETL_ERROR(array_out_of_range));
426
427 iterator p = to_iterator(position);
428
429 etl::move_backward(p, end() - 1, end());
430 *p = value;
431
432 return p;
433 }
434
435 //*************************************************************************
440 //*************************************************************************
441 template <typename TIterator>
442 inline iterator insert_at(size_t position, TIterator first, const TIterator last)
443 {
444 ETL_ASSERT_CHECK_EXTRA(position < SIZE, ETL_ERROR(array_out_of_range));
445
446 return insert(begin() + position, first, last);
447 }
448
449 //*************************************************************************
454 //*************************************************************************
455 template <typename TIterator>
456 iterator insert(const_iterator position, TIterator first, const TIterator last)
457 {
458 ETL_ASSERT_CHECK_EXTRA(cbegin() <= position && position < cend(), ETL_ERROR(array_out_of_range));
459
460 iterator p = to_iterator(position);
461 iterator result(p);
462
463 size_t source_size = static_cast<size_t>(etl::distance(first, last));
464 size_t destination_space = static_cast<size_t>(etl::distance(position, cend()));
465
466 // Do we need to move anything?
467 if (source_size < destination_space)
468 {
469 size_t length = SIZE - (static_cast<size_t>(etl::distance(begin(), p)) + source_size);
470 etl::move_backward(p, p + length, end());
471 }
472
473 // Copy from the range.
474 etl::copy_s(first, last, p, end());
475
476 return result;
477 }
478
479 //*************************************************************************
483 //*************************************************************************
484 inline iterator erase_at(size_t position)
485 {
486 ETL_ASSERT_CHECK_EXTRA(position < SIZE, ETL_ERROR(array_out_of_range));
487
488 return erase(begin() + position);
489 }
490
491 //*************************************************************************
495 //*************************************************************************
496 iterator erase(const_iterator position)
497 {
498 ETL_ASSERT_CHECK_EXTRA(cbegin() <= position && position < cend(), ETL_ERROR(array_out_of_range));
499
500 iterator p = to_iterator(position);
501 etl::move(p + 1, end(), p);
502
503 return p;
504 }
505
506 //*************************************************************************
511 //*************************************************************************
512 iterator erase_range(size_t first, size_t last)
513 {
514 ETL_ASSERT_CHECK_EXTRA(first <= last && last <= SIZE, ETL_ERROR(array_out_of_range));
515
516 return erase(begin() + first, begin() + last);
517 }
518
519 //*************************************************************************
524 //*************************************************************************
525 iterator erase(const_iterator first, const_iterator last)
526 {
527 ETL_ASSERT_CHECK_EXTRA(cbegin() <= first && first <= last && last <= cend(), ETL_ERROR(array_out_of_range));
528
529 iterator p = to_iterator(first);
530 etl::move(last, cend(), p);
531 return p;
532 }
533
534 //*************************************************************************
539 //*************************************************************************
540 inline iterator erase_at(size_t position, parameter_t value)
541 {
542 ETL_ASSERT_CHECK_EXTRA(position < SIZE, ETL_ERROR(array_out_of_range));
543
544 return erase(begin() + position, value);
545 }
546
547 //*************************************************************************
552 //*************************************************************************
553 iterator erase(const_iterator position, parameter_t value)
554 {
555 ETL_ASSERT_CHECK_EXTRA(cbegin() <= position && position < cend(), ETL_ERROR(array_out_of_range));
556
557 iterator p = to_iterator(position);
558
559 etl::move(p + 1, end(), p);
560 back() = value;
561
562 return p;
563 }
564
565 //*************************************************************************
571 //*************************************************************************
572 iterator erase_range(size_t first, size_t last, parameter_t value)
573 {
574 ETL_ASSERT_CHECK_EXTRA(first <= last && last <= SIZE, ETL_ERROR(array_out_of_range));
575
576 return erase(begin() + first, begin() + last, value);
577 }
578
579 //*************************************************************************
585 //*************************************************************************
586 iterator erase(const_iterator first, const_iterator last, parameter_t value)
587 {
588 ETL_ASSERT_CHECK_EXTRA(cbegin() <= first && first <= last && last <= cend(), ETL_ERROR(array_out_of_range));
589
590 iterator p = to_iterator(first);
591
592 p = etl::move(last, cend(), p);
593 etl::fill(p, end(), value);
594
595 return to_iterator(first);
596 }
597
599 T _buffer[SIZE];
600
601 private:
602
603 //*************************************************************************
605 //*************************************************************************
606 iterator to_iterator(const_iterator itr) const
607 {
608 return const_cast<iterator>(itr);
609 }
610 };
611
612 template <typename T, size_t SIZE_>
613 ETL_CONSTANT size_t array<T, SIZE_>::SIZE;
614
615 //***************************************************************************
619 //***************************************************************************
620 template <typename T>
621 class array<T, 0>
622 {
623 private:
624
625 typedef typename etl::parameter_type<T>::type parameter_t;
626
627 public:
628
629 static ETL_CONSTANT size_t SIZE = 0;
630
631 typedef T value_type;
632 typedef size_t size_type;
633 typedef ptrdiff_t difference_type;
634 typedef T& reference;
635 typedef const T& const_reference;
636 typedef T* pointer;
637 typedef const T* const_pointer;
638 typedef T* iterator;
639 typedef const T* const_iterator;
640 typedef ETL_OR_STD::reverse_iterator<iterator> reverse_iterator;
641 typedef ETL_OR_STD::reverse_iterator<const_iterator> const_reverse_iterator;
642
643 //*************************************************************************
644 // Element access
645 //*************************************************************************
646
647 //*************************************************************************
650 //*************************************************************************
651 ETL_NODISCARD ETL_CONSTEXPR14 reference at(size_t) ETL_NOEXCEPT
652 {
653 return *data();
654 }
655
656 //*************************************************************************
659 //*************************************************************************
660 ETL_NODISCARD ETL_CONSTEXPR14 const_reference at(size_t) const ETL_NOEXCEPT
661 {
662 return *data();
663 }
664
665 //*************************************************************************
669 //*************************************************************************
670 ETL_NODISCARD ETL_CONSTEXPR14 reference operator[](size_t) ETL_NOEXCEPT
671 {
672 return *data();
673 }
674
675 //*************************************************************************
679 //*************************************************************************
680 ETL_NODISCARD ETL_CONSTEXPR const_reference operator[](size_t) const ETL_NOEXCEPT
681 {
682 return *data();
683 }
684
685 //*************************************************************************
687 //*************************************************************************
688 ETL_NODISCARD ETL_CONSTEXPR14 reference front() ETL_NOEXCEPT
689 {
690 return *data();
691 }
692
693 //*************************************************************************
695 //*************************************************************************
696 ETL_NODISCARD ETL_CONSTEXPR const_reference front() const ETL_NOEXCEPT
697 {
698 return *data();
699 }
700
701 //*************************************************************************
703 //*************************************************************************
704 ETL_NODISCARD ETL_CONSTEXPR14 reference back() ETL_NOEXCEPT
705 {
706 return *data();
707 }
708
709 //*************************************************************************
711 //*************************************************************************
712 ETL_NODISCARD ETL_CONSTEXPR const_reference back() const
713 {
714 return *data();
715 }
716
717 //*************************************************************************
719 //*************************************************************************
720 ETL_NODISCARD ETL_CONSTEXPR14 pointer data() ETL_NOEXCEPT
721 {
722 return (T*)0;
723 }
724
725 //*************************************************************************
727 //*************************************************************************
728 ETL_NODISCARD ETL_CONSTEXPR const_pointer data() const ETL_NOEXCEPT
729 {
730 return (const T*)0;
731 }
732
733 //*************************************************************************
734 // Iterators
735 //*************************************************************************
736
737 //*************************************************************************
739 //*************************************************************************
740 ETL_NODISCARD ETL_CONSTEXPR14 iterator begin() ETL_NOEXCEPT
741 {
742 return iterator();
743 }
744
745 //*************************************************************************
747 //*************************************************************************
748 ETL_NODISCARD ETL_CONSTEXPR const_iterator begin() const ETL_NOEXCEPT
749 {
750 return const_iterator();
751 }
752
753 //*************************************************************************
755 //*************************************************************************
756 ETL_NODISCARD ETL_CONSTEXPR const_iterator cbegin() const ETL_NOEXCEPT
757 {
758 return const_iterator();
759 }
760
761 //*************************************************************************
763 //*************************************************************************
764 ETL_NODISCARD ETL_CONSTEXPR14 iterator end() ETL_NOEXCEPT
765 {
766 return iterator();
767 }
768
769 //*************************************************************************
771 //*************************************************************************
772 ETL_NODISCARD ETL_CONSTEXPR const_iterator end() const ETL_NOEXCEPT
773 {
774 return const_iterator();
775 }
776
777 //*************************************************************************
778 // Returns a const iterator to the end of the array.
779 //*************************************************************************
780 ETL_NODISCARD ETL_CONSTEXPR const_iterator cend() const ETL_NOEXCEPT
781 {
782 return const_iterator();
783 }
784
785 //*************************************************************************
786 // Returns an reverse iterator to the reverse beginning of the array.
787 //*************************************************************************
788 ETL_NODISCARD ETL_CONSTEXPR14 reverse_iterator rbegin() ETL_NOEXCEPT
789 {
790 return reverse_iterator(end());
791 }
792
793 //*************************************************************************
795 //*************************************************************************
796 ETL_NODISCARD ETL_CONSTEXPR const_reverse_iterator rbegin() const ETL_NOEXCEPT
797 {
798 return const_reverse_iterator(end());
799 }
800
801 //*************************************************************************
803 //*************************************************************************
804 ETL_NODISCARD ETL_CONSTEXPR const_reverse_iterator crbegin() const ETL_NOEXCEPT
805 {
806 return const_reverse_iterator(end());
807 }
808
809 //*************************************************************************
811 //*************************************************************************
812 ETL_NODISCARD ETL_CONSTEXPR14 reverse_iterator rend() ETL_NOEXCEPT
813 {
814 return reverse_iterator(begin());
815 }
816
817 //*************************************************************************
819 //*************************************************************************
820 ETL_NODISCARD ETL_CONSTEXPR const_reverse_iterator rend() const ETL_NOEXCEPT
821 {
822 return const_reverse_iterator(begin());
823 }
824
825 //*************************************************************************
827 //*************************************************************************
828 ETL_NODISCARD ETL_CONSTEXPR const_reverse_iterator crend() const ETL_NOEXCEPT
829 {
830 return const_reverse_iterator(begin());
831 }
832
833 //*************************************************************************
834 // Capacity
835 //*************************************************************************
836
837 //*************************************************************************
839 //*************************************************************************
840 ETL_NODISCARD ETL_CONSTEXPR bool empty() const ETL_NOEXCEPT
841 {
842 return true;
843 }
844
845 //*************************************************************************
847 //*************************************************************************
848 ETL_NODISCARD ETL_CONSTEXPR size_t size() const ETL_NOEXCEPT
849 {
850 return 0;
851 }
852
853 //*************************************************************************
855 //*************************************************************************
856 ETL_NODISCARD ETL_CONSTEXPR size_t max_size() const ETL_NOEXCEPT
857 {
858 return 0;
859 }
860
861 //*************************************************************************
862 // Operations
863 //*************************************************************************
864
865 //*************************************************************************
868 //*************************************************************************
869 ETL_CONSTEXPR14 void fill(parameter_t) ETL_NOEXCEPT
870 {
871 }
872
873 //*************************************************************************
876 //*************************************************************************
877 ETL_CONSTEXPR14 void swap(array&) ETL_NOEXCEPT
878 {
879 }
880
881 //*************************************************************************
888 //*************************************************************************
889 template <typename TIterator>
890 iterator assign(TIterator, const TIterator) ETL_NOEXCEPT
891 {
892 return iterator();
893 }
894
895 //*************************************************************************
902 //*************************************************************************
903 template <typename TIterator>
904 iterator assign(TIterator, const TIterator, parameter_t) ETL_NOEXCEPT
905 {
906 return iterator();
907 }
908
909 //*************************************************************************
913 //*************************************************************************
914 inline iterator insert_at(size_t, parameter_t) ETL_NOEXCEPT
915 {
916 return iterator();
917 }
918
919 //*************************************************************************
923 //*************************************************************************
924 iterator insert(const_iterator, parameter_t) ETL_NOEXCEPT
925 {
926 return iterator();
927 }
928
929 //*************************************************************************
934 //*************************************************************************
935 template <typename TIterator>
936 inline iterator insert_at(size_t, TIterator, const TIterator) ETL_NOEXCEPT
937 {
938 return iterator();
939 }
940
941 //*************************************************************************
946 //*************************************************************************
947 template <typename TIterator>
948 iterator insert(const_iterator, TIterator, const TIterator) ETL_NOEXCEPT
949 {
950 return iterator();
951 }
952
953 //*************************************************************************
957 //*************************************************************************
958 inline iterator erase_at(size_t) ETL_NOEXCEPT
959 {
960 return iterator();
961 }
962
963 //*************************************************************************
967 //*************************************************************************
968 iterator erase(const_iterator) ETL_NOEXCEPT
969 {
970 return iterator();
971 }
972
973 //*************************************************************************
978 //*************************************************************************
979 iterator erase_range(size_t, size_t) ETL_NOEXCEPT
980 {
981 return iterator();
982 }
983
984 //*************************************************************************
989 //*************************************************************************
990 iterator erase(const_iterator, const_iterator) ETL_NOEXCEPT
991 {
992 return iterator();
993 }
994
995 //*************************************************************************
1000 //*************************************************************************
1001 inline iterator erase_at(size_t, parameter_t) ETL_NOEXCEPT
1002 {
1003 return iterator();
1004 }
1005
1006 //*************************************************************************
1011 //*************************************************************************
1012 iterator erase(const_iterator, parameter_t) ETL_NOEXCEPT
1013 {
1014 return iterator();
1015 }
1016
1017 //*************************************************************************
1023 //*************************************************************************
1024 iterator erase_range(size_t, size_t, parameter_t) ETL_NOEXCEPT
1025 {
1026 return iterator();
1027 }
1028
1029 //*************************************************************************
1034 //*************************************************************************
1035 iterator erase(const_iterator, const_iterator, parameter_t) ETL_NOEXCEPT
1036 {
1037 return iterator();
1038 }
1039 };
1040
1041 //*************************************************************************
1043 //*************************************************************************
1044#if ETL_USING_CPP17
1045 template <typename... T>
1046 array(T...) -> array<typename etl::common_type<T...>::type, sizeof...(T)>;
1047#endif
1048
1049 //*************************************************************************
1051 //*************************************************************************
1052#if ETL_HAS_INITIALIZER_LIST
1053 template <typename T, typename... TValues>
1054 constexpr auto make_array(TValues&&... values) ETL_NOEXCEPT -> etl::array<T, sizeof...(TValues)>
1055 {
1056 return {etl::forward<T>(values)...};
1057 }
1058#endif
1059
1060 //*************************************************************************
1064 //*************************************************************************
1065 template <typename T, const size_t SIZE>
1067 {
1068 lhs.swap(rhs);
1069 }
1070
1071 //*************************************************************************
1076 //*************************************************************************
1077 template <typename T, size_t SIZE>
1078 ETL_CONSTEXPR14 bool operator==(const etl::array<T, SIZE>& lhs, const etl::array<T, SIZE>& rhs)
1079 {
1080 return etl::equal(lhs.cbegin(), lhs.cend(), rhs.cbegin());
1081 }
1082
1083 //*************************************************************************
1088 //*************************************************************************
1089 template <typename T, size_t SIZE>
1090 ETL_CONSTEXPR14 bool operator!=(const etl::array<T, SIZE>& lhs, const etl::array<T, SIZE>& rhs)
1091 {
1092 return !(lhs == rhs);
1093 }
1094
1095 //*************************************************************************
1101 //*************************************************************************
1102 template <typename T, size_t SIZE>
1104 {
1105 return etl::lexicographical_compare(lhs.cbegin(), lhs.cend(), rhs.cbegin(), rhs.cend());
1106 }
1107
1108 //*************************************************************************
1115 //*************************************************************************
1116 template <typename T, size_t SIZE>
1118 {
1119 return !(lhs > rhs);
1120 }
1121
1122 //*************************************************************************
1128 template <typename T, size_t SIZE>
1129 //*************************************************************************
1131 {
1132 return (rhs < lhs);
1133 }
1134
1135 //*************************************************************************
1142 //*************************************************************************
1143 template <typename T, size_t SIZE>
1145 {
1146 return !(lhs < rhs);
1147 }
1148
1149 //*************************************************************************
1156 //*************************************************************************
1157 template <size_t Index, typename T, size_t Size>
1158 inline T& get(array<T, Size>& a)
1159 {
1160 ETL_STATIC_ASSERT(Index < Size, "Index out of bounds");
1161 return a[Index];
1162 }
1163
1164 //*************************************************************************
1171 //*************************************************************************
1172 template <size_t Index, typename T, size_t Size>
1173 inline const T& get(const array<T, Size>& a)
1174 {
1175 ETL_STATIC_ASSERT(Index < Size, "Index out of bounds");
1176 return a[Index];
1177 }
1178} // namespace etl
1179
1180#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:2675
ETL_NODISCARD ETL_CONSTEXPR14 reference at(size_t) ETL_NOEXCEPT
Definition array.h:651
ETL_NODISCARD ETL_CONSTEXPR14 reference operator[](size_t i) ETL_NOEXCEPT_EXPR(ETL_NOT_USING_EXCEPTIONS||ETL_NOT_CHECKING_INDEX_OPERATOR)
Definition array.h:137
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:820
ETL_NODISCARD ETL_CONSTEXPR14 reference operator[](size_t) ETL_NOEXCEPT
Definition array.h:670
iterator erase(const_iterator first, const_iterator last)
Definition array.h:525
ETL_NODISCARD ETL_CONSTEXPR14 reverse_iterator rend() ETL_NOEXCEPT
Returns a reverse iterator to the end of the array.
Definition array.h:296
iterator erase_at(size_t) ETL_NOEXCEPT
Definition array.h:958
ETL_NODISCARD ETL_CONSTEXPR const_reference front() const ETL_NOEXCEPT
Returns a const reference to the first element.
Definition array.h:696
ETL_NODISCARD ETL_CONSTEXPR const_reference operator[](size_t) const ETL_NOEXCEPT
Definition array.h:680
iterator assign(TIterator, const TIterator) ETL_NOEXCEPT
Definition array.h:890
ETL_NODISCARD ETL_CONSTEXPR14 reference front() ETL_NOEXCEPT
Returns a reference to the first element.
Definition array.h:164
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:728
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:288
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:280
ETL_NODISCARD ETL_CONSTEXPR14 iterator end() ETL_NOEXCEPT
Returns an iterator to the end of the array.
Definition array.h:764
ETL_NODISCARD ETL_CONSTEXPR14 iterator begin() ETL_NOEXCEPT
Returns an iterator to the beginning of the array.
Definition array.h:224
delegate_type _buffer[SIZE]
Definition array.h:599
ETL_NODISCARD ETL_CONSTEXPR const_iterator begin() const ETL_NOEXCEPT
Returns a const iterator to the beginning of the array.
Definition array.h:232
iterator insert_at(size_t, parameter_t) ETL_NOEXCEPT
Definition array.h:914
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:828
iterator erase_range(size_t, size_t) ETL_NOEXCEPT
Definition array.h:979
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:149
ETL_NODISCARD ETL_CONSTEXPR14 pointer data() ETL_NOEXCEPT
Returns a pointer to the first element of the internal buffer.
Definition array.h:204
iterator erase_range(size_t, size_t, parameter_t) ETL_NOEXCEPT
Definition array.h:1024
iterator erase_range(size_t first, size_t last)
Definition array.h:512
ETL_CONSTEXPR14 void fill(parameter_t) ETL_NOEXCEPT
Definition array.h:869
ETL_NODISCARD ETL_CONSTEXPR const_reference back() const ETL_NOEXCEPT
Returns a const reference to the last element.
Definition array.h:194
ETL_NODISCARD ETL_CONSTEXPR14 reference back() ETL_NOEXCEPT
Returns a reference to the last element.
Definition array.h:184
ETL_NODISCARD ETL_CONSTEXPR14 iterator begin() ETL_NOEXCEPT
Returns an iterator to the beginning of the array.
Definition array.h:740
ETL_CONSTEXPR14 void fill(parameter_t value)
Definition array.h:353
iterator insert_at(size_t, TIterator, const TIterator) ETL_NOEXCEPT
Definition array.h:936
iterator erase(const_iterator) ETL_NOEXCEPT
Definition array.h:968
iterator insert_at(size_t position, parameter_t value)
Definition array.h:411
iterator assign(TIterator, const TIterator, parameter_t) ETL_NOEXCEPT
Definition array.h:904
iterator erase_range(size_t first, size_t last, parameter_t value)
Definition array.h:572
ETL_NODISCARD ETL_CONSTEXPR14 const_reference at(size_t i) const ETL_NOEXCEPT_EXPR(ETL_NOT_USING_EXCEPTIONS)
Definition array.h:125
ETL_NODISCARD ETL_CONSTEXPR const_iterator end() const ETL_NOEXCEPT
Returns a const iterator to the end of the array.
Definition array.h:256
iterator insert(const_iterator, parameter_t) ETL_NOEXCEPT
Definition array.h:924
ETL_NODISCARD ETL_CONSTEXPR size_t max_size() const ETL_NOEXCEPT
Returns the maximum possible size of the array.
Definition array.h:856
ETL_NODISCARD ETL_CONSTEXPR const_iterator end() const ETL_NOEXCEPT
Returns a const iterator to the end of the array.
Definition array.h:772
ETL_NODISCARD ETL_CONSTEXPR size_t size() const ETL_NOEXCEPT
Returns the size of the array.
Definition array.h:848
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:804
ETL_NODISCARD ETL_CONSTEXPR14 const_reference at(size_t) const ETL_NOEXCEPT
Definition array.h:660
ETL_CONSTEXPR14 void swap(array &) ETL_NOEXCEPT
Definition array.h:877
iterator erase_at(size_t position)
Definition array.h:484
ETL_NODISCARD ETL_CONSTEXPR const_reference back() const
Returns a const reference to the last element.
Definition array.h:712
iterator erase(const_iterator first, const_iterator last, parameter_t value)
Definition array.h:586
iterator erase(const_iterator position, parameter_t value)
Definition array.h:553
iterator insert(const_iterator, TIterator, const TIterator) ETL_NOEXCEPT
Definition array.h:948
iterator erase(const_iterator, parameter_t) ETL_NOEXCEPT
Definition array.h:1012
ETL_NODISCARD ETL_CONSTEXPR14 pointer data() ETL_NOEXCEPT
Returns a pointer to the first element of the internal buffer.
Definition array.h:720
ETL_NODISCARD ETL_CONSTEXPR const_iterator cbegin() const ETL_NOEXCEPT
Returns a const iterator to the beginning of the array.
Definition array.h:756
iterator erase(const_iterator, const_iterator) ETL_NOEXCEPT
Definition array.h:990
ETL_NODISCARD ETL_CONSTEXPR14 iterator end() ETL_NOEXCEPT
Returns an iterator to the end of the array.
Definition array.h:248
iterator insert(const_iterator position, parameter_t value)
Definition array.h:423
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:312
ETL_NODISCARD ETL_CONSTEXPR const_iterator begin() const ETL_NOEXCEPT
Returns a const iterator to the beginning of the array.
Definition array.h:748
ETL_NODISCARD ETL_CONSTEXPR bool empty() const ETL_NOEXCEPT
Returns true if the array size is zero.
Definition array.h:324
iterator erase_at(size_t, parameter_t) ETL_NOEXCEPT
Definition array.h:1001
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:212
ETL_NODISCARD ETL_CONSTEXPR size_t size() const ETL_NOEXCEPT
Returns the size of the array.
Definition array.h:332
ETL_NODISCARD ETL_CONSTEXPR14 reference at(size_t i) ETL_NOEXCEPT_EXPR(ETL_NOT_USING_EXCEPTIONS)
Definition array.h:114
ETL_CONSTEXPR14 void swap(array &other) ETL_NOEXCEPT_FROM(ETL_OR_STD
Definition array.h:362
iterator insert(const_iterator position, TIterator first, const TIterator last)
Definition array.h:456
iterator assign(TIterator first, const TIterator last)
Definition array.h:381
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:796
ETL_NODISCARD ETL_CONSTEXPR14 reference front() ETL_NOEXCEPT
Returns a reference to the first element.
Definition array.h:688
ETL_NODISCARD ETL_CONSTEXPR const_iterator cbegin() const ETL_NOEXCEPT
Returns a const iterator to the beginning of the array.
Definition array.h:240
iterator erase(const_iterator position)
Definition array.h:496
ETL_NODISCARD ETL_CONSTEXPR14 reference back() ETL_NOEXCEPT
Returns a reference to the last element.
Definition array.h:704
iterator assign(TIterator first, const TIterator last, parameter_t value)
Definition array.h:395
iterator erase(const_iterator, const_iterator, parameter_t) ETL_NOEXCEPT
Definition array.h:1035
ETL_NODISCARD ETL_CONSTEXPR14 reverse_iterator rend() ETL_NOEXCEPT
Returns a reverse iterator to the end of the array.
Definition array.h:812
iterator erase_at(size_t position, parameter_t value)
Definition array.h:540
ETL_NODISCARD ETL_CONSTEXPR const_reference front() const ETL_NOEXCEPT
Returns a const reference to the first element.
Definition array.h:174
iterator insert_at(size_t position, TIterator first, const TIterator last)
Definition array.h:442
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:304
ETL_NODISCARD ETL_CONSTEXPR bool empty() const ETL_NOEXCEPT
Returns true if the array size is zero.
Definition array.h:840
ETL_NODISCARD ETL_CONSTEXPR size_t max_size() const ETL_NOEXCEPT
Returns the maximum possible size of the array.
Definition array.h:340
Definition array.h:85
Definition array.h:70
#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 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_CONSTEXPR14 bool operator==(const etl::array< T, SIZE > &lhs, const etl::array< T, SIZE > &rhs)
Definition array.h:1078
bool operator>(const etl::array< T, SIZE > &lhs, const etl::array< T, SIZE > &rhs)
Definition array.h:1130
bool operator>=(const etl::array< T, SIZE > &lhs, const etl::array< T, SIZE > &rhs)
Definition array.h:1144
ETL_CONSTEXPR14 bool operator!=(const etl::array< T, SIZE > &lhs, const etl::array< T, SIZE > &rhs)
Definition array.h:1090
T & get(array< T, Size > &a)
Definition array.h:1158
TContainer::const_iterator cend(const TContainer &container)
Definition iterator.h:1186
bool operator<(const etl::array< T, SIZE > &lhs, const etl::array< T, SIZE > &rhs)
Definition array.h:1103
bool operator<=(const etl::array< T, SIZE > &lhs, const etl::array< T, SIZE > &rhs)
Definition array.h:1117
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:46