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 "functional.h"
39#include "initializer_list.h"
40#include "iterator.h"
41#include "nth_type.h"
42#include "parameter_type.h"
43#include "static_assert.h"
44#include "type_traits.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 ETL_CONSTEXPR14 reference at(size_t i) ETL_NOEXCEPT_EXPR(ETL_NOT_USING_EXCEPTIONS)
118 {
119 ETL_ASSERT(i < SIZE, ETL_ERROR(array_out_of_range));
120
121 return _buffer[i];
122 }
123
124 //*************************************************************************
127 //*************************************************************************
128 ETL_NODISCARD ETL_CONSTEXPR14 const_reference at(size_t i) const ETL_NOEXCEPT_EXPR(ETL_NOT_USING_EXCEPTIONS)
129 {
130 ETL_ASSERT(i < SIZE, ETL_ERROR(array_out_of_range));
131
132 return _buffer[i];
133 }
134
135 //*************************************************************************
139 //*************************************************************************
140 ETL_NODISCARD ETL_CONSTEXPR14 reference operator[](size_t i) ETL_NOEXCEPT_EXPR(ETL_NOT_USING_EXCEPTIONS || ETL_NOT_CHECKING_INDEX_OPERATOR)
141 {
142 ETL_ASSERT_CHECK_INDEX_OPERATOR(i < SIZE, ETL_ERROR(array_out_of_range));
143
144 return _buffer[i];
145 }
146
147 //*************************************************************************
151 //*************************************************************************
152 ETL_NODISCARD ETL_CONSTEXPR const_reference operator[](size_t i) const ETL_NOEXCEPT_EXPR(ETL_NOT_USING_EXCEPTIONS || ETL_NOT_CHECKING_INDEX_OPERATOR)
153 {
154 // Throwing from c++11 constexpr requires special syntax
155#if ETL_USING_CPP11 && ETL_NOT_USING_CPP14 && ETL_USING_EXCEPTIONS && ETL_CHECKING_INDEX_OPERATOR
156 return i < SIZE ? _buffer[i] : throw(ETL_ERROR(array_out_of_range));
157#else
158 ETL_ASSERT_CHECK_INDEX_OPERATOR(i < SIZE, ETL_ERROR(array_out_of_range));
159
160 return _buffer[i];
161#endif
162 }
163
164 //*************************************************************************
166 //*************************************************************************
167 ETL_NODISCARD ETL_CONSTEXPR14 reference front() ETL_NOEXCEPT
168 {
169 ETL_STATIC_ASSERT(SIZE > 0, "Array is empty.");
170
171 return _buffer[0];
172 }
173
174 //*************************************************************************
176 //*************************************************************************
177 ETL_NODISCARD ETL_CONSTEXPR const_reference front() const ETL_NOEXCEPT
178 {
179 ETL_STATIC_ASSERT(SIZE > 0, "Array is empty.");
180
181 return _buffer[0];
182 }
183
184 //*************************************************************************
186 //*************************************************************************
187 ETL_NODISCARD ETL_CONSTEXPR14 reference back() ETL_NOEXCEPT
188 {
189 ETL_STATIC_ASSERT(SIZE > 0, "Array is empty.");
190
191 return _buffer[SIZE - 1];
192 }
193
194 //*************************************************************************
196 //*************************************************************************
197 ETL_NODISCARD ETL_CONSTEXPR const_reference back() const ETL_NOEXCEPT
198 {
199 ETL_STATIC_ASSERT(SIZE > 0, "Array is empty.");
200
201 return _buffer[SIZE - 1];
202 }
203
204 //*************************************************************************
206 //*************************************************************************
207 ETL_NODISCARD ETL_CONSTEXPR14 pointer data() ETL_NOEXCEPT
208 {
209 return _buffer;
210 }
211
212 //*************************************************************************
214 //*************************************************************************
215 ETL_NODISCARD ETL_CONSTEXPR const_pointer data() const ETL_NOEXCEPT
216 {
217 return _buffer;
218 }
219
220 //*************************************************************************
221 // Iterators
222 //*************************************************************************
223
224 //*************************************************************************
226 //*************************************************************************
227 ETL_NODISCARD ETL_CONSTEXPR14 iterator begin() ETL_NOEXCEPT
228 {
229 return _buffer;
230 }
231
232 //*************************************************************************
234 //*************************************************************************
235 ETL_NODISCARD ETL_CONSTEXPR const_iterator begin() const ETL_NOEXCEPT
236 {
237 return _buffer;
238 }
239
240 //*************************************************************************
242 //*************************************************************************
243 ETL_NODISCARD ETL_CONSTEXPR const_iterator cbegin() const ETL_NOEXCEPT
244 {
245 return begin();
246 }
247
248 //*************************************************************************
250 //*************************************************************************
251 ETL_NODISCARD ETL_CONSTEXPR14 iterator end() ETL_NOEXCEPT
252 {
253 return _buffer + SIZE;
254 }
255
256 //*************************************************************************
258 //*************************************************************************
259 ETL_NODISCARD ETL_CONSTEXPR const_iterator end() const ETL_NOEXCEPT
260 {
261 return _buffer + SIZE;
262 }
263
264 //*************************************************************************
265 // Returns a const iterator to the end of the array.
266 //*************************************************************************
267 ETL_NODISCARD ETL_CONSTEXPR const_iterator cend() const ETL_NOEXCEPT
268 {
269 return _buffer + SIZE;
270 }
271
272 //*************************************************************************
273 // Returns an reverse iterator to the reverse beginning of the array.
274 //*************************************************************************
275 ETL_NODISCARD ETL_CONSTEXPR14 reverse_iterator rbegin() ETL_NOEXCEPT
276 {
277 return reverse_iterator(end());
278 }
279
280 //*************************************************************************
282 //*************************************************************************
283 ETL_NODISCARD ETL_CONSTEXPR const_reverse_iterator rbegin() const ETL_NOEXCEPT
284 {
285 return const_reverse_iterator(end());
286 }
287
288 //*************************************************************************
290 //*************************************************************************
291 ETL_NODISCARD ETL_CONSTEXPR const_reverse_iterator crbegin() const ETL_NOEXCEPT
292 {
293 return const_reverse_iterator(end());
294 }
295
296 //*************************************************************************
298 //*************************************************************************
299 ETL_NODISCARD ETL_CONSTEXPR14 reverse_iterator rend() ETL_NOEXCEPT
300 {
301 return reverse_iterator(begin());
302 }
303
304 //*************************************************************************
306 //*************************************************************************
307 ETL_NODISCARD ETL_CONSTEXPR const_reverse_iterator rend() const ETL_NOEXCEPT
308 {
309 return const_reverse_iterator(begin());
310 }
311
312 //*************************************************************************
314 //*************************************************************************
315 ETL_NODISCARD ETL_CONSTEXPR const_reverse_iterator crend() const ETL_NOEXCEPT
316 {
317 return const_reverse_iterator(begin());
318 }
319
320 //*************************************************************************
321 // Capacity
322 //*************************************************************************
323
324 //*************************************************************************
326 //*************************************************************************
327 ETL_NODISCARD ETL_CONSTEXPR bool empty() const ETL_NOEXCEPT
328 {
329 return (SIZE == 0);
330 }
331
332 //*************************************************************************
334 //*************************************************************************
335 ETL_NODISCARD ETL_CONSTEXPR size_t size() const ETL_NOEXCEPT
336 {
337 return SIZE;
338 }
339
340 //*************************************************************************
342 //*************************************************************************
343 ETL_NODISCARD ETL_CONSTEXPR size_t max_size() const ETL_NOEXCEPT
344 {
345 return SIZE;
346 }
347
348 //*************************************************************************
349 // Operations
350 //*************************************************************************
351
352 //*************************************************************************
355 //*************************************************************************
356 ETL_CONSTEXPR14 void fill(parameter_t value)
357 {
358 etl::fill(_buffer, _buffer + SIZE, value);
359 }
360
361 //*************************************************************************
364 //*************************************************************************
365 ETL_CONSTEXPR14 void swap(array& other) ETL_NOEXCEPT_FROM(ETL_OR_STD::swap(etl::declval<T&>(), etl::declval<T&>()))
366 {
367 using ETL_OR_STD::swap; // Allow ADL
368
369 for (size_t i = 0UL; i < SIZE; ++i)
370 {
371 swap(_buffer[i], other._buffer[i]);
372 }
373 }
374
375 //*************************************************************************
382 //*************************************************************************
383 template <typename TIterator>
384 iterator assign(TIterator first, const TIterator last)
385 {
386 return etl::copy_s(first, last, begin(), end());
387 }
388
389 //*************************************************************************
396 //*************************************************************************
397 template <typename TIterator>
398 iterator assign(TIterator first, const TIterator last, parameter_t value)
399 {
400 // Copy from the range.
401 iterator p = etl::copy_s(first, last, begin(), end());
402
403 // Initialise any that are left.
404 etl::fill(p, end(), value);
405
406 return p;
407 }
408
409 //*************************************************************************
413 //*************************************************************************
414 inline iterator insert_at(size_t position, parameter_t value)
415 {
416 ETL_ASSERT_CHECK_EXTRA(position < SIZE, ETL_ERROR(array_out_of_range));
417
418 return insert(begin() + position, value);
419 }
420
421 //*************************************************************************
425 //*************************************************************************
426 iterator insert(const_iterator position, parameter_t value)
427 {
428 ETL_ASSERT_CHECK_EXTRA(cbegin() <= position && position < cend(), ETL_ERROR(array_out_of_range));
429
430 iterator p = to_iterator(position);
431
432 etl::move_backward(p, end() - 1, end());
433 *p = value;
434
435 return p;
436 }
437
438 //*************************************************************************
443 //*************************************************************************
444 template <typename TIterator>
445 inline iterator insert_at(size_t position, TIterator first, const TIterator last)
446 {
447 ETL_ASSERT_CHECK_EXTRA(position < SIZE, ETL_ERROR(array_out_of_range));
448
449 return insert(begin() + position, first, last);
450 }
451
452 //*************************************************************************
457 //*************************************************************************
458 template <typename TIterator>
459 iterator insert(const_iterator position, TIterator first, const TIterator last)
460 {
461 ETL_ASSERT_CHECK_EXTRA(cbegin() <= position && position < cend(), ETL_ERROR(array_out_of_range));
462
463 iterator p = to_iterator(position);
464 iterator result(p);
465
466 size_t source_size = static_cast<size_t>(etl::distance(first, last));
467 size_t destination_space = static_cast<size_t>(etl::distance(position, cend()));
468
469 // Do we need to move anything?
470 if (source_size < destination_space)
471 {
472 size_t length = SIZE - (static_cast<size_t>(etl::distance(begin(), p)) + source_size);
473 etl::move_backward(p, p + length, end());
474 }
475
476 // Copy from the range.
477 etl::copy_s(first, last, p, end());
478
479 return result;
480 }
481
482 //*************************************************************************
486 //*************************************************************************
487 inline iterator erase_at(size_t position)
488 {
489 ETL_ASSERT_CHECK_EXTRA(position < SIZE, ETL_ERROR(array_out_of_range));
490
491 return erase(begin() + position);
492 }
493
494 //*************************************************************************
498 //*************************************************************************
499 iterator erase(const_iterator position)
500 {
501 ETL_ASSERT_CHECK_EXTRA(cbegin() <= position && position < cend(), ETL_ERROR(array_out_of_range));
502
503 iterator p = to_iterator(position);
504 etl::move(p + 1, end(), p);
505
506 return p;
507 }
508
509 //*************************************************************************
514 //*************************************************************************
515 iterator erase_range(size_t first, size_t last)
516 {
517 ETL_ASSERT_CHECK_EXTRA(first <= last && last <= SIZE, ETL_ERROR(array_out_of_range));
518
519 return erase(begin() + first, begin() + last);
520 }
521
522 //*************************************************************************
527 //*************************************************************************
528 iterator erase(const_iterator first, const_iterator last)
529 {
530 ETL_ASSERT_CHECK_EXTRA(cbegin() <= first && first <= last && last <= cend(), ETL_ERROR(array_out_of_range));
531
532 iterator p = to_iterator(first);
533 etl::move(last, cend(), p);
534 return p;
535 }
536
537 //*************************************************************************
542 //*************************************************************************
543 inline iterator erase_at(size_t position, parameter_t value)
544 {
545 ETL_ASSERT_CHECK_EXTRA(position < SIZE, ETL_ERROR(array_out_of_range));
546
547 return erase(begin() + position, value);
548 }
549
550 //*************************************************************************
555 //*************************************************************************
556 iterator erase(const_iterator position, parameter_t value)
557 {
558 ETL_ASSERT_CHECK_EXTRA(cbegin() <= position && position < cend(), ETL_ERROR(array_out_of_range));
559
560 iterator p = to_iterator(position);
561
562 etl::move(p + 1, end(), p);
563 back() = value;
564
565 return p;
566 }
567
568 //*************************************************************************
574 //*************************************************************************
575 iterator erase_range(size_t first, size_t last, parameter_t value)
576 {
577 ETL_ASSERT_CHECK_EXTRA(first <= last && last <= SIZE, ETL_ERROR(array_out_of_range));
578
579 return erase(begin() + first, begin() + last, value);
580 }
581
582 //*************************************************************************
588 //*************************************************************************
589 iterator erase(const_iterator first, const_iterator last, parameter_t value)
590 {
591 ETL_ASSERT_CHECK_EXTRA(cbegin() <= first && first <= last && last <= cend(), ETL_ERROR(array_out_of_range));
592
593 iterator p = to_iterator(first);
594
595 p = etl::move(last, cend(), p);
596 etl::fill(p, end(), value);
597
598 return to_iterator(first);
599 }
600
602 T _buffer[SIZE];
603
604 private:
605
606 //*************************************************************************
608 //*************************************************************************
609 iterator to_iterator(const_iterator itr) const
610 {
611 return const_cast<iterator>(itr);
612 }
613 };
614
615 template <typename T, size_t SIZE_>
616 ETL_CONSTANT size_t array<T, SIZE_>::SIZE;
617
618 //***************************************************************************
622 //***************************************************************************
623 template <typename T>
624 class array<T, 0>
625 {
626 private:
627
628 typedef typename etl::parameter_type<T>::type parameter_t;
629
630 public:
631
632 static ETL_CONSTANT size_t SIZE = 0;
633
634 typedef T value_type;
635 typedef size_t size_type;
636 typedef ptrdiff_t difference_type;
637 typedef T& reference;
638 typedef const T& const_reference;
639 typedef T* pointer;
640 typedef const T* const_pointer;
641 typedef T* iterator;
642 typedef const T* const_iterator;
643 typedef ETL_OR_STD::reverse_iterator<iterator> reverse_iterator;
644 typedef ETL_OR_STD::reverse_iterator<const_iterator> const_reverse_iterator;
645
646 //*************************************************************************
647 // Element access
648 //*************************************************************************
649
650 //*************************************************************************
653 //*************************************************************************
654 ETL_NODISCARD ETL_CONSTEXPR14 reference at(size_t) ETL_NOEXCEPT
655 {
656 return *data();
657 }
658
659 //*************************************************************************
662 //*************************************************************************
663 ETL_NODISCARD ETL_CONSTEXPR14 const_reference at(size_t) const ETL_NOEXCEPT
664 {
665 return *data();
666 }
667
668 //*************************************************************************
672 //*************************************************************************
673 ETL_NODISCARD ETL_CONSTEXPR14 reference operator[](size_t) ETL_NOEXCEPT
674 {
675 return *data();
676 }
677
678 //*************************************************************************
682 //*************************************************************************
683 ETL_NODISCARD ETL_CONSTEXPR const_reference operator[](size_t) const ETL_NOEXCEPT
684 {
685 return *data();
686 }
687
688 //*************************************************************************
690 //*************************************************************************
691 ETL_NODISCARD ETL_CONSTEXPR14 reference front() ETL_NOEXCEPT
692 {
693 return *data();
694 }
695
696 //*************************************************************************
698 //*************************************************************************
699 ETL_NODISCARD ETL_CONSTEXPR const_reference front() const ETL_NOEXCEPT
700 {
701 return *data();
702 }
703
704 //*************************************************************************
706 //*************************************************************************
707 ETL_NODISCARD ETL_CONSTEXPR14 reference back() ETL_NOEXCEPT
708 {
709 return *data();
710 }
711
712 //*************************************************************************
714 //*************************************************************************
715 ETL_NODISCARD ETL_CONSTEXPR const_reference back() const
716 {
717 return *data();
718 }
719
720 //*************************************************************************
722 //*************************************************************************
723 ETL_NODISCARD ETL_CONSTEXPR14 pointer data() ETL_NOEXCEPT
724 {
725 return (T*)0;
726 }
727
728 //*************************************************************************
730 //*************************************************************************
731 ETL_NODISCARD ETL_CONSTEXPR const_pointer data() const ETL_NOEXCEPT
732 {
733 return (const T*)0;
734 }
735
736 //*************************************************************************
737 // Iterators
738 //*************************************************************************
739
740 //*************************************************************************
742 //*************************************************************************
743 ETL_NODISCARD ETL_CONSTEXPR14 iterator begin() ETL_NOEXCEPT
744 {
745 return iterator();
746 }
747
748 //*************************************************************************
750 //*************************************************************************
751 ETL_NODISCARD ETL_CONSTEXPR const_iterator begin() const ETL_NOEXCEPT
752 {
753 return const_iterator();
754 }
755
756 //*************************************************************************
758 //*************************************************************************
759 ETL_NODISCARD ETL_CONSTEXPR const_iterator cbegin() const ETL_NOEXCEPT
760 {
761 return const_iterator();
762 }
763
764 //*************************************************************************
766 //*************************************************************************
767 ETL_NODISCARD ETL_CONSTEXPR14 iterator end() ETL_NOEXCEPT
768 {
769 return iterator();
770 }
771
772 //*************************************************************************
774 //*************************************************************************
775 ETL_NODISCARD ETL_CONSTEXPR const_iterator end() const ETL_NOEXCEPT
776 {
777 return const_iterator();
778 }
779
780 //*************************************************************************
781 // Returns a const iterator to the end of the array.
782 //*************************************************************************
783 ETL_NODISCARD ETL_CONSTEXPR const_iterator cend() const ETL_NOEXCEPT
784 {
785 return const_iterator();
786 }
787
788 //*************************************************************************
789 // Returns an reverse iterator to the reverse beginning of the array.
790 //*************************************************************************
791 ETL_NODISCARD ETL_CONSTEXPR14 reverse_iterator rbegin() ETL_NOEXCEPT
792 {
793 return reverse_iterator(end());
794 }
795
796 //*************************************************************************
798 //*************************************************************************
799 ETL_NODISCARD ETL_CONSTEXPR const_reverse_iterator rbegin() const ETL_NOEXCEPT
800 {
801 return const_reverse_iterator(end());
802 }
803
804 //*************************************************************************
806 //*************************************************************************
807 ETL_NODISCARD ETL_CONSTEXPR const_reverse_iterator crbegin() const ETL_NOEXCEPT
808 {
809 return const_reverse_iterator(end());
810 }
811
812 //*************************************************************************
814 //*************************************************************************
815 ETL_NODISCARD ETL_CONSTEXPR14 reverse_iterator rend() ETL_NOEXCEPT
816 {
817 return reverse_iterator(begin());
818 }
819
820 //*************************************************************************
822 //*************************************************************************
823 ETL_NODISCARD ETL_CONSTEXPR const_reverse_iterator rend() const ETL_NOEXCEPT
824 {
825 return const_reverse_iterator(begin());
826 }
827
828 //*************************************************************************
830 //*************************************************************************
831 ETL_NODISCARD ETL_CONSTEXPR const_reverse_iterator crend() const ETL_NOEXCEPT
832 {
833 return const_reverse_iterator(begin());
834 }
835
836 //*************************************************************************
837 // Capacity
838 //*************************************************************************
839
840 //*************************************************************************
842 //*************************************************************************
843 ETL_NODISCARD ETL_CONSTEXPR bool empty() const ETL_NOEXCEPT
844 {
845 return true;
846 }
847
848 //*************************************************************************
850 //*************************************************************************
851 ETL_NODISCARD ETL_CONSTEXPR size_t size() const ETL_NOEXCEPT
852 {
853 return 0;
854 }
855
856 //*************************************************************************
858 //*************************************************************************
859 ETL_NODISCARD ETL_CONSTEXPR size_t max_size() const ETL_NOEXCEPT
860 {
861 return 0;
862 }
863
864 //*************************************************************************
865 // Operations
866 //*************************************************************************
867
868 //*************************************************************************
871 //*************************************************************************
872 ETL_CONSTEXPR14 void fill(parameter_t) ETL_NOEXCEPT
873 {
874 }
875
876 //*************************************************************************
879 //*************************************************************************
880 ETL_CONSTEXPR14 void swap(array&) ETL_NOEXCEPT
881 {
882 }
883
884 //*************************************************************************
891 //*************************************************************************
892 template <typename TIterator>
893 iterator assign(TIterator, const TIterator) ETL_NOEXCEPT
894 {
895 return iterator();
896 }
897
898 //*************************************************************************
905 //*************************************************************************
906 template <typename TIterator>
907 iterator assign(TIterator, const TIterator, parameter_t) ETL_NOEXCEPT
908 {
909 return iterator();
910 }
911
912 //*************************************************************************
916 //*************************************************************************
917 inline iterator insert_at(size_t, parameter_t) ETL_NOEXCEPT
918 {
919 return iterator();
920 }
921
922 //*************************************************************************
926 //*************************************************************************
927 iterator insert(const_iterator, parameter_t) ETL_NOEXCEPT
928 {
929 return iterator();
930 }
931
932 //*************************************************************************
937 //*************************************************************************
938 template <typename TIterator>
939 inline iterator insert_at(size_t, TIterator, const TIterator) ETL_NOEXCEPT
940 {
941 return iterator();
942 }
943
944 //*************************************************************************
949 //*************************************************************************
950 template <typename TIterator>
951 iterator insert(const_iterator, TIterator, const TIterator) ETL_NOEXCEPT
952 {
953 return iterator();
954 }
955
956 //*************************************************************************
960 //*************************************************************************
961 inline iterator erase_at(size_t) ETL_NOEXCEPT
962 {
963 return iterator();
964 }
965
966 //*************************************************************************
970 //*************************************************************************
971 iterator erase(const_iterator) ETL_NOEXCEPT
972 {
973 return iterator();
974 }
975
976 //*************************************************************************
981 //*************************************************************************
982 iterator erase_range(size_t, size_t) ETL_NOEXCEPT
983 {
984 return iterator();
985 }
986
987 //*************************************************************************
992 //*************************************************************************
993 iterator erase(const_iterator, const_iterator) ETL_NOEXCEPT
994 {
995 return iterator();
996 }
997
998 //*************************************************************************
1003 //*************************************************************************
1004 inline iterator erase_at(size_t, parameter_t) ETL_NOEXCEPT
1005 {
1006 return iterator();
1007 }
1008
1009 //*************************************************************************
1014 //*************************************************************************
1015 iterator erase(const_iterator, parameter_t) ETL_NOEXCEPT
1016 {
1017 return iterator();
1018 }
1019
1020 //*************************************************************************
1026 //*************************************************************************
1027 iterator erase_range(size_t, size_t, parameter_t) ETL_NOEXCEPT
1028 {
1029 return iterator();
1030 }
1031
1032 //*************************************************************************
1037 //*************************************************************************
1038 iterator erase(const_iterator, const_iterator, parameter_t) ETL_NOEXCEPT
1039 {
1040 return iterator();
1041 }
1042 };
1043
1044 //*************************************************************************
1046 //*************************************************************************
1047#if ETL_USING_CPP17
1048 template <typename... T>
1049 array(T...) -> array<typename etl::common_type<T...>::type, sizeof...(T)>;
1050#endif
1051
1052 //*************************************************************************
1054 //*************************************************************************
1055#if ETL_HAS_INITIALIZER_LIST
1056 template <typename T, typename... TValues>
1057 constexpr auto make_array(TValues&&... values) ETL_NOEXCEPT -> etl::array<T, sizeof...(TValues)>
1058 {
1059 return {etl::forward<T>(values)...};
1060 }
1061#endif
1062
1063 //*************************************************************************
1067 //*************************************************************************
1068 template <typename T, const size_t SIZE>
1070 {
1071 lhs.swap(rhs);
1072 }
1073
1074 //*************************************************************************
1079 //*************************************************************************
1080 template <typename T, size_t SIZE>
1081 ETL_CONSTEXPR14 bool operator==(const etl::array<T, SIZE>& lhs, const etl::array<T, SIZE>& rhs)
1082 {
1083 return etl::equal(lhs.cbegin(), lhs.cend(), rhs.cbegin());
1084 }
1085
1086 //*************************************************************************
1091 //*************************************************************************
1092 template <typename T, size_t SIZE>
1093 ETL_CONSTEXPR14 bool operator!=(const etl::array<T, SIZE>& lhs, const etl::array<T, SIZE>& rhs)
1094 {
1095 return !(lhs == rhs);
1096 }
1097
1098 //*************************************************************************
1104 //*************************************************************************
1105 template <typename T, size_t SIZE>
1107 {
1108 return etl::lexicographical_compare(lhs.cbegin(), lhs.cend(), rhs.cbegin(), rhs.cend());
1109 }
1110
1111 //*************************************************************************
1118 //*************************************************************************
1119 template <typename T, size_t SIZE>
1121 {
1122 return !(lhs > rhs);
1123 }
1124
1125 //*************************************************************************
1131 template <typename T, size_t SIZE>
1132 //*************************************************************************
1134 {
1135 return (rhs < lhs);
1136 }
1137
1138 //*************************************************************************
1145 //*************************************************************************
1146 template <typename T, size_t SIZE>
1148 {
1149 return !(lhs < rhs);
1150 }
1151
1152 //*************************************************************************
1159 //*************************************************************************
1160 template <size_t Index, typename T, size_t Size>
1161 inline T& get(array<T, Size>& a)
1162 {
1163 ETL_STATIC_ASSERT(Index < Size, "Index out of bounds");
1164 return a[Index];
1165 }
1166
1167 //*************************************************************************
1174 //*************************************************************************
1175 template <size_t Index, typename T, size_t Size>
1176 inline const T& get(const array<T, Size>& a)
1177 {
1178 ETL_STATIC_ASSERT(Index < Size, "Index out of bounds");
1179 return a[Index];
1180 }
1181} // namespace etl
1182
1183#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:2638
ETL_NODISCARD ETL_CONSTEXPR14 reference at(size_t) ETL_NOEXCEPT
Definition array.h:654
ETL_NODISCARD ETL_CONSTEXPR14 reference operator[](size_t i) ETL_NOEXCEPT_EXPR(ETL_NOT_USING_EXCEPTIONS||ETL_NOT_CHECKING_INDEX_OPERATOR)
Definition array.h:140
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:823
ETL_NODISCARD ETL_CONSTEXPR14 reference operator[](size_t) ETL_NOEXCEPT
Definition array.h:673
iterator erase(const_iterator first, const_iterator last)
Definition array.h:528
ETL_NODISCARD ETL_CONSTEXPR14 reverse_iterator rend() ETL_NOEXCEPT
Returns a reverse iterator to the end of the array.
Definition array.h:299
iterator erase_at(size_t) ETL_NOEXCEPT
Definition array.h:961
ETL_NODISCARD ETL_CONSTEXPR const_reference front() const ETL_NOEXCEPT
Returns a const reference to the first element.
Definition array.h:699
ETL_NODISCARD ETL_CONSTEXPR const_reference operator[](size_t) const ETL_NOEXCEPT
Definition array.h:683
iterator assign(TIterator, const TIterator) ETL_NOEXCEPT
Definition array.h:893
ETL_NODISCARD ETL_CONSTEXPR14 reference front() ETL_NOEXCEPT
Returns a reference to the first element.
Definition array.h:167
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:731
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:291
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:283
ETL_NODISCARD ETL_CONSTEXPR14 iterator end() ETL_NOEXCEPT
Returns an iterator to the end of the array.
Definition array.h:767
ETL_NODISCARD ETL_CONSTEXPR14 iterator begin() ETL_NOEXCEPT
Returns an iterator to the beginning of the array.
Definition array.h:227
delegate_type _buffer[SIZE]
Definition array.h:602
ETL_NODISCARD ETL_CONSTEXPR const_iterator begin() const ETL_NOEXCEPT
Returns a const iterator to the beginning of the array.
Definition array.h:235
iterator insert_at(size_t, parameter_t) ETL_NOEXCEPT
Definition array.h:917
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:831
iterator erase_range(size_t, size_t) ETL_NOEXCEPT
Definition array.h:982
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:152
ETL_NODISCARD ETL_CONSTEXPR14 pointer data() ETL_NOEXCEPT
Returns a pointer to the first element of the internal buffer.
Definition array.h:207
iterator erase_range(size_t, size_t, parameter_t) ETL_NOEXCEPT
Definition array.h:1027
iterator erase_range(size_t first, size_t last)
Definition array.h:515
ETL_CONSTEXPR14 void fill(parameter_t) ETL_NOEXCEPT
Definition array.h:872
ETL_NODISCARD ETL_CONSTEXPR const_reference back() const ETL_NOEXCEPT
Returns a const reference to the last element.
Definition array.h:197
ETL_NODISCARD ETL_CONSTEXPR14 reference back() ETL_NOEXCEPT
Returns a reference to the last element.
Definition array.h:187
ETL_NODISCARD ETL_CONSTEXPR14 iterator begin() ETL_NOEXCEPT
Returns an iterator to the beginning of the array.
Definition array.h:743
ETL_CONSTEXPR14 void fill(parameter_t value)
Definition array.h:356
iterator insert_at(size_t, TIterator, const TIterator) ETL_NOEXCEPT
Definition array.h:939
iterator erase(const_iterator) ETL_NOEXCEPT
Definition array.h:971
iterator insert_at(size_t position, parameter_t value)
Definition array.h:414
iterator assign(TIterator, const TIterator, parameter_t) ETL_NOEXCEPT
Definition array.h:907
iterator erase_range(size_t first, size_t last, parameter_t value)
Definition array.h:575
ETL_NODISCARD ETL_CONSTEXPR14 const_reference at(size_t i) const ETL_NOEXCEPT_EXPR(ETL_NOT_USING_EXCEPTIONS)
Definition array.h:128
ETL_NODISCARD ETL_CONSTEXPR const_iterator end() const ETL_NOEXCEPT
Returns a const iterator to the end of the array.
Definition array.h:259
iterator insert(const_iterator, parameter_t) ETL_NOEXCEPT
Definition array.h:927
ETL_NODISCARD ETL_CONSTEXPR size_t max_size() const ETL_NOEXCEPT
Returns the maximum possible size of the array.
Definition array.h:859
ETL_NODISCARD ETL_CONSTEXPR const_iterator end() const ETL_NOEXCEPT
Returns a const iterator to the end of the array.
Definition array.h:775
ETL_NODISCARD ETL_CONSTEXPR size_t size() const ETL_NOEXCEPT
Returns the size of the array.
Definition array.h:851
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:807
ETL_NODISCARD ETL_CONSTEXPR14 const_reference at(size_t) const ETL_NOEXCEPT
Definition array.h:663
ETL_CONSTEXPR14 void swap(array &) ETL_NOEXCEPT
Definition array.h:880
iterator erase_at(size_t position)
Definition array.h:487
ETL_NODISCARD ETL_CONSTEXPR const_reference back() const
Returns a const reference to the last element.
Definition array.h:715
iterator erase(const_iterator first, const_iterator last, parameter_t value)
Definition array.h:589
iterator erase(const_iterator position, parameter_t value)
Definition array.h:556
iterator insert(const_iterator, TIterator, const TIterator) ETL_NOEXCEPT
Definition array.h:951
iterator erase(const_iterator, parameter_t) ETL_NOEXCEPT
Definition array.h:1015
ETL_NODISCARD ETL_CONSTEXPR14 pointer data() ETL_NOEXCEPT
Returns a pointer to the first element of the internal buffer.
Definition array.h:723
ETL_NODISCARD ETL_CONSTEXPR const_iterator cbegin() const ETL_NOEXCEPT
Returns a const iterator to the beginning of the array.
Definition array.h:759
iterator erase(const_iterator, const_iterator) ETL_NOEXCEPT
Definition array.h:993
ETL_NODISCARD ETL_CONSTEXPR14 iterator end() ETL_NOEXCEPT
Returns an iterator to the end of the array.
Definition array.h:251
iterator insert(const_iterator position, parameter_t value)
Definition array.h:426
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:315
ETL_NODISCARD ETL_CONSTEXPR const_iterator begin() const ETL_NOEXCEPT
Returns a const iterator to the beginning of the array.
Definition array.h:751
ETL_NODISCARD ETL_CONSTEXPR bool empty() const ETL_NOEXCEPT
Returns true if the array size is zero.
Definition array.h:327
iterator erase_at(size_t, parameter_t) ETL_NOEXCEPT
Definition array.h:1004
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:215
ETL_NODISCARD ETL_CONSTEXPR size_t size() const ETL_NOEXCEPT
Returns the size of the array.
Definition array.h:335
ETL_NODISCARD ETL_CONSTEXPR14 reference at(size_t i) ETL_NOEXCEPT_EXPR(ETL_NOT_USING_EXCEPTIONS)
Definition array.h:117
ETL_CONSTEXPR14 void swap(array &other) ETL_NOEXCEPT_FROM(ETL_OR_STD
Definition array.h:365
iterator insert(const_iterator position, TIterator first, const TIterator last)
Definition array.h:459
iterator assign(TIterator first, const TIterator last)
Definition array.h:384
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:799
ETL_NODISCARD ETL_CONSTEXPR14 reference front() ETL_NOEXCEPT
Returns a reference to the first element.
Definition array.h:691
ETL_NODISCARD ETL_CONSTEXPR const_iterator cbegin() const ETL_NOEXCEPT
Returns a const iterator to the beginning of the array.
Definition array.h:243
iterator erase(const_iterator position)
Definition array.h:499
ETL_NODISCARD ETL_CONSTEXPR14 reference back() ETL_NOEXCEPT
Returns a reference to the last element.
Definition array.h:707
iterator assign(TIterator first, const TIterator last, parameter_t value)
Definition array.h:398
iterator erase(const_iterator, const_iterator, parameter_t) ETL_NOEXCEPT
Definition array.h:1038
ETL_NODISCARD ETL_CONSTEXPR14 reverse_iterator rend() ETL_NOEXCEPT
Returns a reverse iterator to the end of the array.
Definition array.h:815
iterator erase_at(size_t position, parameter_t value)
Definition array.h:543
ETL_NODISCARD ETL_CONSTEXPR const_reference front() const ETL_NOEXCEPT
Returns a const reference to the first element.
Definition array.h:177
iterator insert_at(size_t position, TIterator first, const TIterator last)
Definition array.h:445
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:307
ETL_NODISCARD ETL_CONSTEXPR bool empty() const ETL_NOEXCEPT
Returns true if the array size is zero.
Definition array.h:843
ETL_NODISCARD ETL_CONSTEXPR size_t max_size() const ETL_NOEXCEPT
Returns the maximum possible size of the array.
Definition array.h:343
Definition array.h:88
Definition array.h:73
#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
bitset_ext
Definition absolute.h:40
ETL_CONSTEXPR14 void swap(etl::typed_storage_ext< T > &lhs, etl::typed_storage_ext< T > &rhs) ETL_NOEXCEPT
Swap two etl::typed_storage_ext.
Definition alignment.h:856
ETL_CONSTEXPR14 bool operator==(const etl::array< T, SIZE > &lhs, const etl::array< T, SIZE > &rhs)
Definition array.h:1081
bool operator>(const etl::array< T, SIZE > &lhs, const etl::array< T, SIZE > &rhs)
Definition array.h:1133
bool operator>=(const etl::array< T, SIZE > &lhs, const etl::array< T, SIZE > &rhs)
Definition array.h:1147
ETL_CONSTEXPR14 bool operator!=(const etl::array< T, SIZE > &lhs, const etl::array< T, SIZE > &rhs)
Definition array.h:1093
T & get(array< T, Size > &a)
Definition array.h:1161
ETL_CONSTEXPR TContainer::const_iterator cend(const TContainer &container)
Definition iterator.h:1017
bool operator<(const etl::array< T, SIZE > &lhs, const etl::array< T, SIZE > &rhs)
Definition array.h:1106
bool operator<=(const etl::array< T, SIZE > &lhs, const etl::array< T, SIZE > &rhs)
Definition array.h:1120
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