YSTest: iterator.hpp 源文件

YSTest PreAlpha_b500_20140530 The YSLib Test Project

- 首页
- 相关页面
- 模块
- 命名空间
- 类
- 文件

- 文件列表
- 文件成员

全部 类 命名空间 文件 函数 变量 类型定义 枚举 枚举值 友元 宏定义 组 页
iterator.hpp
浏览该文件的文档.
1 /*
2 © 2011-2014 FrankHB.
3
4 This file is part of the YSLib project, and may only be used,
5 modified, and distributed under the terms of the YSLib project
6 license, LICENSE.TXT. By continuing to use, modify, or distribute
7 this file you indicate that you have read the license and
8 understand and accept it fully.
9 */
10
28 #ifndef YB_INC_ystdex_iterator_hpp_
29 #define YB_INC_ystdex_iterator_hpp_ 1
30
31 #include "type_op.hpp" // for ystdex::remove_reference_t, ystdex::*_tag;
32 #include "cassert.h"
33 #include <iterator> // for std::make_move_iterator, std::iterator,
34 // std::iterator_traits;
35 #include <utility> // for std::make_pair;
36 #include <memory> // for std::addressof;
37
38 namespace ystdex
39 {
40
57 template<typename _tParam, typename = yimpl(std::pair<
58 decltype(*std::declval<_tParam&>()), decltype(++std::declval<_tParam&>())>)>
59 using enable_for_iterator_t = enable_if_t<
60 is_same<decltype(++std::declval<_tParam&>()), _tParam&>::value, int>;
61
62
69
77 template<typename _tIterator>
78 yconstfn bool
79 is_undereferenceable(const _tIterator&) ynothrow
80 {
81 return false;
82 }
83 template<typename _type>
84 yconstfn bool
85 is_undereferenceable(_type* p) ynothrow
86 {
87 return !bool(p);
88 }
90
97 template<typename _tIn, typename _fPred>
98 _tIn
99 next_if(_tIn i, _fPred f,
100 typename std::iterator_traits<_tIn>::difference_type n = 1)
101 {
102 yconstraint(!is_undereferenceable(i));
103 return f(*i) ? std::next(i, n) : i;
104 }
105 template<typename _tIn, typename _type>
106 _tIn
107 next_if_eq(_tIn i, const _type& val,
108 typename std::iterator_traits<_tIn>::difference_type n = 1)
109 {
110 yconstraint(!is_undereferenceable(i));
111 return *i == val ? std::next(i, n) : i;
112 }
114
120 template<typename _tBi, typename _fPred>
121 _tBi
122 prev_if(_tBi i, _fPred f,
123 typename std::iterator_traits<_tBi>::difference_type n = 1)
124 {
125 return f(*i) ? std::prev(i, n) : i;
126 }
127 template<typename _tBi, typename _type>
128 _tBi
129 prev_if_eq(_tBi i, const _type& val,
130 typename std::iterator_traits<_tBi>::difference_type n = 1)
131 {
132 return *i == val ? std::prev(i, n) : i;
133 }
135
137
138
144 template<typename _tIterator1, typename _tIterator2>
145 inline auto
146 make_move_iterator_pair(_tIterator1 it1, _tIterator2 it2) -> decltype(
147 std::make_pair(std::make_move_iterator(it1), std::make_move_iterator(it2)))
148 {
149 return std::make_pair(std::make_move_iterator(it1),
150 std::make_move_iterator(it2));
151 }
158 template<typename _tRange>
159 inline auto
160 make_move_iterator_pair(_tRange& c)
161 -> decltype(ystdex::make_move_iterator_pair(begin(c), end(c)))
162 {
163 return ystdex::make_move_iterator_pair(begin(c), end(c));
164 }
165
166
177 template<typename _type>
178 class pointer_iterator
179 {
180 public:
181 using iterator_type = _type*;
182 using iterator_category
183 = typename std::iterator_traits<iterator_type>::iterator_category;
184 using value_type = typename std::iterator_traits<iterator_type>::value_type;
185 using difference_type
186 = typename std::iterator_traits<iterator_type>::difference_type;
187 using pointer = typename std::iterator_traits<iterator_type>::pointer;
188 using reference = typename std::iterator_traits<iterator_type>::reference;
189
190 protected:
192 pointer raw;
193
194 public:
195 yconstfn
196 pointer_iterator(nullptr_t = {})
197 : raw()
198 {}
200 template<typename _tPointer>
201 explicit yconstfn
202 pointer_iterator(_tPointer&& ptr)
203 : raw(yforward(ptr))
204 {}
205 inline
206 pointer_iterator(const pointer_iterator&) = default;
207
209 pointer_iterator&
210 operator+=(difference_type n)
211 {
212 yconstraint(raw);
213 raw += n;
214 return *this;
215 }
216
218 pointer_iterator&
219 operator-=(difference_type n)
220 {
221 yconstraint(raw);
222 raw -= n;
223 return *this;
224 }
225
227 reference
228 operator*() const ynothrowv
229 {
230 yconstraint(raw);
231 return *raw;
232 }
233
234 yconstfn pointer
235 operator->() const
236 {
237 return raw;
238 }
239
240 inline pointer_iterator&
241 operator++()
242 {
243 yconstraint(raw);
244 ++raw;
245 return *this;
246 }
248 pointer_iterator
249 operator++(int)
250 {
251 return raw++;
252 }
253
254 inline pointer_iterator&
255 operator--()
256 {
257 --raw;
258 return *this;
259 }
261 pointer_iterator
262 operator--(int)
263 {
264 return raw--;
265 }
266
268 reference
269 operator[](difference_type n) const
270 {
271 yconstraint(raw);
272
273 return raw[n];
274 }
275
277 yconstfn pointer_iterator
278 operator+(difference_type n) const
279 {
280 return pointer_iterator(raw + n);
281 }
282
284 yconstfn pointer_iterator
285 operator-(difference_type n) const
286 {
287 return pointer_iterator(raw - n);
288 }
289
290 yconstfn
291 operator pointer() const
292 {
293 return raw;
294 }
295 };
296
302 template<typename _type>
303 inline bool
304 operator==(const pointer_iterator<_type>& x, const pointer_iterator<_type>& y)
305 {
306 using pointer = typename pointer_iterator<_type>::pointer;
307
308 return pointer(x) == pointer(y);
309 }
310
311 template<typename _type>
312 inline bool
313 operator!=(const pointer_iterator<_type>& x, const pointer_iterator<_type>& y)
314 {
315 return !(x == y);
316 }
318
319
328 template<typename _type>
329 struct pointer_classify
330 {
331 using type = _type;
332 };
333
334 template<typename _type>
335 struct pointer_classify<_type*>
336 {
337 using type = pointer_iterator<_type>;
338 };
340
341
349 template<typename _type, typename _tIterator = _type*,
350 typename _tTraits = std::iterator_traits<_tIterator>>
351 class pseudo_iterator
352 {
353 public:
354 using iterator_type = _tIterator;
356 using traits_type = _tTraits;
357 using iterator_category = typename traits_type::iterator_category;
358 using value_type = typename traits_type::value_type;
359 using difference_type = typename traits_type::difference_type;
360 using pointer = typename traits_type::pointer;
361 using reference = typename traits_type::reference;
362
363 value_type value;
364
365 yconstfn
366 pseudo_iterator()
367 : value()
368 {}
369 explicit yconstfn
370 pseudo_iterator(value_type v)
371 : value(v)
372 {}
373 yconstfn
374 pseudo_iterator(const pseudo_iterator&) = default;
375 yconstfn
376 #if YB_IMPL_MSCPP
377 pseudo_iterator(pseudo_iterator&& i)
379 : value(std::move(i.value))
380 {}
381 #else
382 pseudo_iterator(pseudo_iterator&&) = default;
383 #endif
384
385 pseudo_iterator&
386 operator=(const pseudo_iterator&) = default;
387 pseudo_iterator&
388 #if YB_IMPL_MSCPP
389 operator=(pseudo_iterator&& i)
391 {
392 value = std::move(i.value);
393 return *this;
394 }
395 #else
396 operator=(pseudo_iterator&&) = default;
397 #endif
398
400 pseudo_iterator&
401 operator+=(difference_type)
402 {
403 return *this;
404 }
405
407 pseudo_iterator&
408 operator-=(difference_type)
409 {
410 return *this;
411 }
412
414
415 yconstfn reference
416 operator*() const
417 {
418 return value;
419 }
420
421 yconstfn pointer
422 operator->() const
423 {
424 return this;
425 }
426
427 pseudo_iterator&
428 operator++()
429 {
430 return *this;
431 }
432 pseudo_iterator
433 operator++(int)
434 {
435 return *this;
436 }
438
440
441 yconstfn pseudo_iterator&
442 operator--() const
443 {
444 return *this;
445 }
446 yconstfn pseudo_iterator
447 operator--(int) const
448 {
449 return *this;
450 }
452
458 yconstfn reference
459 operator[](difference_type n) const
460 {
461 return this[n];
462 }
463
464 yconstfn pseudo_iterator
465 operator+(difference_type) const
466 {
467 return *this;
468 }
469
470 yconstfn pseudo_iterator
471 operator-(difference_type) const
472 {
473 return *this;
474 }
476 };
477
484 template<typename _type, typename _tIterator, typename _tTraits>
485 inline bool
486 operator==(const pseudo_iterator<_type, _tIterator, _tTraits>& x,
487 const pseudo_iterator<_type, _tIterator, _tTraits>& y)
488 {
489 return x.value == y.value;
490 }
491
492 template<typename _type, typename _tIterator, typename _tTraits>
493 inline bool
494 operator!=(const pseudo_iterator<_type, _tIterator, _tTraits>& x,
495 const pseudo_iterator<_type, _tIterator, _tTraits>& y)
496 {
497 return !(x == y);
498 }
500
501
513 template<typename _tIterator, typename _fTransformer>
514 class transformed_iterator : public pointer_classify<_tIterator>::type
515 {
516 public:
521 using iterator_type = typename
522 pointer_classify<remove_reference_t<_tIterator>>::type;
523 using transformer_type = decay_t<_fTransformer>;
525 using transformed_type = result_of_t<_fTransformer&(_tIterator&)>;
527 using difference_type
528 = typename pointer_classify<_tIterator>::type::difference_type;
530 using reference = decltype(std::declval<transformed_type>());
531
532 protected:
534 mutable transformer_type transformer;
535
536 public:
538 transformed_iterator() = default;
540 template<typename _tIter, typename _tTran,
541 yimpl(typename = exclude_self_ctor_t<transformed_iterator, _tIter>)>
542 explicit yconstfn
543 transformed_iterator(_tIter&& i, _tTran f = {})
544 : iterator_type(yforward(i)), transformer(f)
545 {}
547
548 transformed_iterator(const transformed_iterator&) = default;
549 transformed_iterator(transformed_iterator&&) = default;
551
553 inline reference
554 operator*() const
555 {
556 return yforward(transformer(get()));
557 }
558
560 template<typename _tDiff>
561 enable_if_t<is_convertible<decltype(
562 std::declval<iterator_type&>()[_tDiff()]), reference>::value, reference>
563 operator[](_tDiff n)
564 {
565 return get()[difference_type(n)];
566 }
567
572 inline
573 operator iterator_type&()
574 {
575 return *this;
576 }
577
582 yconstfn
583 operator const iterator_type&() const
584 {
585 return *this;
586 }
587
592 inline iterator_type&
593 get()
594 {
595 return *this;
596 }
597
602 yconstfn const iterator_type&
603 get() const
604 {
605 return *this;
606 }
607
609
610 transformer_type&
611 get_transformer() ynothrow
612 {
613 return transformer;
614 }
615 yconstfn const transformer_type&
616 get_transformer() const ynothrow
617 {
618 return transformer;
619 }
621 };
622
629 template<typename _type, typename _fTransformer>
630 inline bool
631 operator==(const transformed_iterator<_type, _fTransformer>& x,
632 const transformed_iterator<_type, _fTransformer>& y)
633 {
634 return x.get() == y.get();
635 }
636
637 template<typename _type, typename _fTransformer>
638 inline bool
639 operator!=(const transformed_iterator<_type, _fTransformer>& x,
640 const transformed_iterator<_type, _fTransformer>& y)
641 {
642 return !(x == y);
643 }
645
652 template<typename _type, typename _fTransformer>
653 inline transformed_iterator<_type, _fTransformer>&
654 operator+=(transformed_iterator<_type, _fTransformer>& i,
655 typename transformed_iterator<_type, _fTransformer>::difference_type n)
656 {
657 i.get() += n;
658 return i;
659 }
660
661 template<typename _type, typename _fTransformer>
662 inline transformed_iterator<_type, _fTransformer>&
663 operator-=(transformed_iterator<_type, _fTransformer>& i,
664 typename transformed_iterator<_type, _fTransformer>::difference_type n)
665 {
666 i.get() -= n;
667 return i;
668 }
669
670 template<typename _type, typename _fTransformer>
671 transformed_iterator<_type, _fTransformer>
672 operator+(const transformed_iterator<_type, _fTransformer>& i,
673 typename transformed_iterator<_type, _fTransformer>::difference_type n)
674 {
675 auto it(i);
676
677 it += n;
678 return it;
679 }
680
681 template<typename _type, typename _fTransformer>
682 transformed_iterator<_type, _fTransformer>
683 operator-(const transformed_iterator<_type, _fTransformer>& i,
684 typename transformed_iterator<_type, _fTransformer>::difference_type n)
685 {
686 auto it(i);
687
688 it -= n;
689 return it;
690 }
691 template<typename _type, typename _fTransformer>
692 typename transformed_iterator<_type, _fTransformer>::difference_type
693 operator-(const transformed_iterator<_type, _fTransformer>& x,
694 const transformed_iterator<_type, _fTransformer>& y)
695 {
696 return x.get() - y.get();
697 }
698
699 template<typename _type, typename _fTransformer>
700 inline bool
701 operator<(const transformed_iterator<_type, _fTransformer>& x,
702 const transformed_iterator<_type, _fTransformer>& y)
703 {
704 return bool(x.get() < y.get());
705 }
706
707 template<typename _type, typename _fTransformer>
708 inline bool
709 operator<=(const transformed_iterator<_type, _fTransformer>& x,
710 const transformed_iterator<_type, _fTransformer>& y)
711 {
712 return !(y < x);
713 }
714
715 template<typename _type, typename _fTransformer>
716 inline bool
717 operator>(const transformed_iterator<_type, _fTransformer>& x,
718 const transformed_iterator<_type, _fTransformer>& y)
719 {
720 return y < x;
721 }
722
723 template<typename _type, typename _fTransformer>
724 inline bool
725 operator>=(const transformed_iterator<_type, _fTransformer>& x,
726 const transformed_iterator<_type, _fTransformer>& y)
727 {
728 return !(x < y);
729 }
731
732
739 template<typename _tIterator, typename _fTransformer>
740 inline transformed_iterator<typename array_ref_decay<_tIterator>::type,
741 _fTransformer>
742 make_transform(_tIterator&& i, _fTransformer f)
743 {
744 return transformed_iterator<typename array_ref_decay<_tIterator>::type,
745 _fTransformer>(yforward(i), f);
746 }
747
748
753 namespace iterator_transformation
754 {
756
757 template<typename _tIterator>
758 static yconstfn auto
759 first(const _tIterator& i) -> decltype((i->first))
760 {
761 return i->first;
762 }
763 template<typename _tIterator>
764 static yconstfn auto
765 second(const _tIterator& i) -> decltype((i->second))
766 {
767 return i->second;
768 }
769 template<typename _tIterator>
770 static yconstfn auto
771 indirect(const _tIterator& i) -> decltype((**i))
772 {
773 return **i;
774 }
776 } // namespace iterator_transformation;
777
778
784 yconstexpr first_tag get_first{}, get_key{};
785 yconstexpr second_tag get_second{}, get_value{};
787 yconstexpr struct indirect_tag{} get_indirect{};
789
790
795 template<typename _tIterator>
796 inline auto
797 operator|(_tIterator&& i, first_tag)
798 -> decltype(make_transform(yforward(i), iterator_transformation::first<
799 typename array_ref_decay<_tIterator>::type>))
800 {
801 return make_transform(yforward(i), iterator_transformation::first<
802 typename array_ref_decay<_tIterator>::type>);
803 }
804 template<typename _tIterator>
805 inline auto
806 operator|(_tIterator&& i, second_tag)
807 -> decltype(make_transform(yforward(i), iterator_transformation::second<
808 typename array_ref_decay<_tIterator>::type>))
809 {
810 return make_transform(yforward(i), iterator_transformation::second<
811 typename array_ref_decay<_tIterator>::type>);
812 }
814 template<typename _tIterator>
815 inline auto
816 operator|(_tIterator&& i, indirect_tag)
817 -> decltype(make_transform(yforward(i), iterator_transformation::indirect<
818 typename array_ref_decay<_tIterator>::type>))
819 {
820 return make_transform(yforward(i), iterator_transformation::indirect<
821 typename array_ref_decay<_tIterator>::type>);
822 }
823
824
833 template<typename _tMaster, typename _tSlave,
834 class _tTraits = std::iterator_traits<_tMaster>>
835 class pair_iterator : private std::pair<_tMaster, _tSlave>
836 {
837 public:
838 using pair_type = std::pair<_tMaster, _tSlave>;
839 using iterator_type = _tMaster;
841 using traits_type = _tTraits;
842 using iterator_category = typename traits_type::iterator_category;
843 using value_type = typename traits_type::value_type;
844 using difference_type = typename traits_type::difference_type;
845 using pointer = typename traits_type::pointer;
846 using reference = typename traits_type::reference;
847
848 yconstfn
849 pair_iterator()
850 : std::pair<_tMaster, _tSlave>(_tMaster(), _tSlave())
851 {}
852 explicit yconstfn
853 pair_iterator(const _tMaster& _i)
854 : std::pair<_tMaster, _tSlave>(_i, _tSlave())
855 {}
856 yconstfn
857 pair_iterator(const _tMaster& _i, const _tSlave& _s)
858 : std::pair<_tMaster, _tSlave>(_i, _s)
859 {}
860 yconstfn
861 pair_iterator(const pair_iterator&) = default;
862 yconstfn
863 pair_iterator(pair_iterator&& _r)
864 : std::pair<_tMaster, _tSlave>(std::move(_r))
865 {}
866
867 inline pair_iterator&
868 operator=(const pair_iterator&) = default;
869 inline pair_iterator&
870 #if YB_IMPL_MSCPP
871 operator=(pair_iterator&& i)
873 {
874 static_cast<std::pair<_tMaster, _tSlave>&>(*this)
875 = static_cast<std::pair<_tMaster, _tSlave>&&>(i);
876 return *this;
877 }
878 #else
879 operator=(pair_iterator&&) = default;
880 #endif
881
883 pair_iterator&
884 operator+=(difference_type n)
885 {
886 yunseq(this->first += n, this->second += n);
887 return *this;
888 }
889
891 pair_iterator&
892 operator-=(difference_type n)
893 {
894 yunseq(this->first -= n, this->second -= n);
895 return *this;
896 }
897
899
900 yconstfn reference
901 operator*() const
902 {
903 return *this->first;
904 }
905
906 yconstfn pointer
907 operator->() const
908 {
909 return this->first;
910 }
911
912 pair_iterator&
913 operator++()
914 {
915 yunseq(++this->first, ++this->second);
916 return *this;
917 }
918 pair_iterator
919 operator++(int)
920 {
921 auto i(*this);
922
923 ++*this;
924 return i;
925 }
927
929
930 pair_iterator&
931 operator--()
932 {
933 yunseq(--this->first, --this->second);
934 return *this;
935 }
936 pair_iterator
937 operator--(int)
938 {
939 auto i(*this);
940
941 --*this;
942 return i;
943 }
945
951 yconstfn reference
952 operator[](difference_type n) const
953 {
954 return this->first[n];
955 }
956
957 pair_iterator
958 operator+(difference_type n) const
959 {
960 auto i(*this);
961
962 yunseq(i.first += n, i.second += n);
963 return i;
964 }
965
966 pair_iterator
967 operator-(difference_type n) const
968 {
969 auto i(*this);
970
971 yunseq(i.first -= n, i.second -= n);
972 return i;
973 }
975
977 template<typename _tFirst, typename _tSecond,
978 typename = enable_if_t<is_convertible<_tMaster, _tFirst>::value
979 && is_convertible<_tSlave, _tSecond>::value, int>>
980 operator std::pair<_tFirst, _tSecond>()
981 {
982 return std::pair<_tFirst, _tSecond>(this->first, this->second);
983 }
984
985 yconstfn const pair_type&
986 base() const
987 {
988 return *this;
989 }
990 };
991
997 template<typename _tMaster, typename _tSlave>
998 bool
999 operator==(const pair_iterator<_tMaster, _tSlave>& x,
1000 const pair_iterator<_tMaster, _tSlave>& y)
1001 {
1002 return x.base().first == y.base().first
1003 && x.base().second == y.base().second();
1004 }
1005
1006 template<typename _tMaster, typename _tSlave>
1007 inline bool
1008 operator!=(const pair_iterator<_tMaster, _tSlave>& x,
1009 const pair_iterator<_tMaster, _tSlave>& y)
1010 {
1011 return !(x == y);
1012 }
1014
1015
1022 template<typename _tIterator>
1023 class indirect_input_iterator
1024 {
1025 public:
1026 using iterator_type = _tIterator;
1027 using iterator_category = std::input_iterator_tag;
1028 using value_type = typename std::iterator_traits<iterator_type>::value_type;
1029 using difference_type
1030 = typename std::iterator_traits<iterator_type>::difference_type;
1031 using pointer = typename std::iterator_traits<iterator_type>::pointer;
1032 using reference = typename std::iterator_traits<iterator_type>::reference;
1033
1034 private:
1035 iterator_type iter;
1036
1037 public:
1038 indirect_input_iterator()
1039 : iter()
1040 {}
1041 indirect_input_iterator(iterator_type i)
1042 : iter(i)
1043 {
1044 ++*this;
1045 }
1046 indirect_input_iterator(const indirect_input_iterator&) = default;
1048 indirect_input_iterator(indirect_input_iterator&& i) ynothrow
1049 : iter()
1050 {
1051 using std::swap;
1052
1053 swap(iter, i.iter);
1054 }
1055
1056 indirect_input_iterator&
1057 operator=(const indirect_input_iterator&) = default;
1058 indirect_input_iterator&
1059 #if YB_IMPL_MSCPP
1060 operator=(indirect_input_iterator&& i)
1062 {
1063 iter = std::move(i.iter);
1064 return *this;
1065 }
1066 #else
1067 operator=(indirect_input_iterator&&) = default;
1068 #endif
1069
1070 pointer
1071 operator->() const
1072 {
1073 return (*iter).operator->();
1074 }
1075
1077 template<typename = enable_if_t<is_constructible<bool,
1078 decltype(*std::declval<iterator_type&>())>::value, int>>
1079 explicit
1080 operator bool() const
1081 // operator bool() const ynoexcept((!is_undereferenceable(std::declval<
1082 // iterator_type&>()) && bool(*std::declval<iterator_type&>())))
1083 {
1084 return !is_undereferenceable(iter) && bool(*iter);
1085 }
1086
1092 reference
1093 operator*() const
1094 {
1095 yconstraint(!is_undereferenceable(iter));
1096 return **iter;
1097 }
1098
1103 indirect_input_iterator&
1104 operator++()
1105 {
1106 yconstraint(!is_undereferenceable(iter));
1107 ++*iter;
1108 return *this;
1109 }
1110 indirect_input_iterator
1111 operator++(int)
1112 {
1113 const auto i(*this);
1114
1115 ++*this;
1116 return i;
1117 }
1118
1119 friend bool
1120 operator==(const indirect_input_iterator& x, const indirect_input_iterator& y)
1121 {
1122 return (!bool(x) && !bool(y)) || x.iter == y.iter;
1123 }
1124
1125 iterator_type&
1126 get() ynothrow
1127 {
1128 return iter;
1129 }
1130 const iterator_type&
1131 get() const ynothrow
1132 {
1133 return iter;
1134 }
1135 };
1136
1141 template<typename _tIterator>
1142 inline bool
1143 operator!=(const indirect_input_iterator<_tIterator>& x,
1144 const indirect_input_iterator<_tIterator>& y)
1145 {
1146 return !(x == y);
1147 }
1148
1149
1161 #if YB_IMPL_MSCPP || YB_IMPL_CLANGPP
1163 template<unsigned char _vN, bool _bEndian = false>
1164 #else
1165 template<unsigned char _vN, bool _bEndian = {}>
1166 #endif
1167 class bitseg_iterator : public std::iterator<std::random_access_iterator_tag,
1168 byte, ptrdiff_t, byte*, byte&>
1169 {
1170 static_assert(_vN != 0, "A bit segment should contain at least one bit.");
1171 static_assert(_vN != CHAR_BIT, "A bit segment should not be a byte.");
1172 static_assert(CHAR_BIT % _vN == 0,
1173 "A byte should be divided by number of segments without padding.");
1174
1175 public:
1176 using difference_type = ptrdiff_t;
1177 using pointer = byte*;
1178 using reference = byte&;
1179
1180 static yconstexpr unsigned char seg_n = CHAR_BIT / _vN;
1181 static yconstexpr unsigned char seg_size = 1 << _vN;
1182 static yconstexpr unsigned char seg_width = _vN;
1183
1184 protected:
1185 byte* base;
1186 unsigned char shift;
1187 mutable byte value;
1188
1189 public:
1191
1192
1197 bitseg_iterator(byte* p = {}, unsigned char n = 0) ynothrow
1198 : base(p), shift(n)
1199 {
1200 yassume(shift < seg_n);
1201 }
1202
1203 bitseg_iterator&
1204 operator+=(difference_type n) ynothrowv
1205 {
1206 yconstraint(base);
1207 yassume(shift < seg_n);
1208
1209 const size_t new_shift(shift + n);
1210
1211 yunseq(base += new_shift / seg_n, shift = new_shift % seg_n);
1212 return *this;
1213 }
1214
1215 bitseg_iterator&
1216 operator-=(difference_type n) ynothrowv
1217 {
1218 base += -n;
1219 return *this;
1220 }
1221
1222 reference
1223 operator*() const ynothrowv
1224 {
1225 yconstraint(base);
1226 return value = *base >> seg_width * (_bEndian ? seg_n - 1 - shift
1227 : seg_width) & seg_width;
1228 }
1229
1230 yconstfn pointer
1231 operator->() const ynothrowv
1232 {
1233 return &**this;
1234 }
1235
1236 inline bitseg_iterator&
1237 operator++() ynothrowv
1238 {
1239 yconstraint(base);
1240 yassume(shift < seg_n);
1241 if(++shift == seg_n)
1242 yunseq(shift = 0, ++base);
1243 return *this;
1244 }
1246 bitseg_iterator
1247 operator++(int) ynothrowv
1248 {
1249 auto i(*this);
1250
1251 ++*this;
1252 return i;
1253 }
1254
1255 inline bitseg_iterator&
1256 operator--() ynothrowv
1257 {
1258 yconstraint(base);
1259 yassume(shift < seg_n);
1260 if(shift == 0)
1261 yunseq(--base, shift = seg_n - 1);
1262 else
1263 --shift;
1264 return *this;
1265 }
1267 bitseg_iterator
1268 operator--(int) ynothrowv
1269 {
1270 auto i(*this);
1271
1272 --*this;
1273 return i;
1274 }
1275
1276 reference
1277 operator[](difference_type n) const ynothrowv
1278 {
1279 const auto i(*this);
1280
1281 i += n;
1282 return *i.operator->();
1283 }
1284
1285 yconstfn bitseg_iterator
1286 operator+(difference_type n) const ynothrow
1287 {
1288 return bitseg_iterator(base + n);
1289 }
1290
1291 yconstfn bitseg_iterator
1292 operator-(difference_type n) const ynothrow
1293 {
1294 return bitseg_iterator(base - n);
1295 }
1296
1297 yconstfn explicit
1298 operator pointer() const ynothrow
1299 {
1300 return base;
1301 }
1302
1303 yconstfn size_t
1304 get_shift() const ynothrow
1305 {
1306 return shift;
1307 }
1309 };
1310
1316 template<size_t _vN, bool _bEndian>
1317 inline bool
1318 operator==(const bitseg_iterator<_vN, _bEndian>& x,
1319 const bitseg_iterator<_vN, _bEndian>& y)
1320 {
1321 using pointer = typename bitseg_iterator<_vN, _bEndian>::pointer;
1322
1323 return pointer(x) == pointer(y) && x.get_shift() == y.get_shift();
1324 }
1325
1326 template<size_t _vN, bool _bEndian>
1327 inline bool
1328 operator!=(const bitseg_iterator<_vN, _bEndian>& x,
1329 const bitseg_iterator<_vN, _bEndian>& y)
1330 {
1331 return !(x == y);
1332 }
1333
1334 template<size_t _vN, bool _bEndian>
1335 inline bool
1336 operator<(const bitseg_iterator<_vN, _bEndian>& x,
1337 const bitseg_iterator<_vN, _bEndian>& y)
1338 {
1339 using pointer = typename bitseg_iterator<_vN, _bEndian>::pointer;
1340
1341 return pointer(x) < pointer(y)
1342 || (pointer(x) == pointer(y) && x.get_shift() < y.get_shift());
1343 }
1344
1345 template<size_t _vN, bool _bEndian>
1346 bool
1347 operator<=(const bitseg_iterator<_vN, _bEndian>& x,
1348 const bitseg_iterator<_vN, _bEndian>& y)
1349 {
1350 return !(y < x);
1351 }
1352
1353 template<size_t _vN, bool _bEndian>
1354 bool
1355 operator>(const bitseg_iterator<_vN, _bEndian>& x,
1356 const bitseg_iterator<_vN, _bEndian>& y)
1357 {
1358 return y < x;
1359 }
1360
1361 template<size_t _vN, bool _bEndian>
1362 bool
1363 operator>=(const bitseg_iterator<_vN, _bEndian>& x,
1364 const bitseg_iterator<_vN, _bEndian>& y)
1365 {
1366 return !(x < y);
1367 }
1369
1370
1379 template<class _tCon, typename _type>
1380 class subscriptive_iterator
1381 {
1382 public:
1383 using container_type = _tCon;
1384 using iterator_category = std::random_access_iterator_tag;
1385 using value_type = _type;
1386 using difference_type = ptrdiff_t;
1387 using pointer = _type*;
1388 using reference = _type&;
1389
1390 protected:
1392 _tCon* con_ptr;
1393 size_t idx;
1394
1395 public:
1396 yconstfn
1397 subscriptive_iterator(_tCon& c, size_t i)
1398 : con_ptr(std::addressof(c)), idx(i)
1399 {}
1400
1401 subscriptive_iterator&
1402 operator+=(difference_type n)
1403 {
1404 idx += n;
1405 return *this;
1406 }
1407
1408 subscriptive_iterator&
1409 operator-=(difference_type n)
1410 {
1411 yassume(!(idx < n));
1412 idx -= n;
1413 return *this;
1414 }
1415
1417
1418 reference
1419 operator*() const
1420 {
1421 return (*con_ptr)[idx];
1422 }
1423
1424 pointer
1425 operator->() const
1426 {
1427 return std::addressof(**this);
1428 }
1429
1430 subscriptive_iterator&
1431 operator++() ynothrow
1432 {
1433 ++idx;
1434 return *this;
1435 }
1436 subscriptive_iterator
1437 operator++(int) ynothrow
1438 {
1439 auto i(*this);
1440
1441 ++*this;
1442 return i;
1443 }
1444
1445 subscriptive_iterator
1446 operator--() ynothrow
1447 {
1448 --idx;
1449 return *this;
1450 }
1451 subscriptive_iterator
1452 operator--(int) ynothrow
1453 {
1454 auto i(*this);
1455
1456 --*this;
1457 return i;
1458 }
1460
1461 reference
1462 operator[](difference_type n) const
1463 {
1464 yassume(!(idx + n < 0));
1465 return (*con_ptr)[idx + n];
1466 }
1467
1468 subscriptive_iterator
1469 operator+(difference_type n) const
1470 {
1471 yassume(!(idx + n < 0));
1472 return subscriptive_iterator(*con_ptr, idx + n);
1473 }
1474
1475 subscriptive_iterator
1476 operator-(difference_type n) const
1477 {
1478 yassume(!(idx + n < 0));
1479 return subscriptive_iterator(*con_ptr, idx - n);
1480 }
1481
1483 _tCon*
1484 container() const ynothrow
1485 {
1486 return con_ptr;
1487 }
1488
1490 bool
1491 equals(const subscriptive_iterator<_tCon, _type>& i) const ynothrow
1492 {
1493 return con_ptr == i.con_ptr && idx == i.idx;
1494 }
1495
1497 size_t
1498 index() const ynothrow
1499 {
1500 return idx;
1501 }
1502 };
1503
1509 template<class _tCon, typename _type>
1511 bool
1512 operator==(const subscriptive_iterator<_tCon, _type>& x,
1513 const subscriptive_iterator<_tCon, _type>& y) ynothrow
1514 {
1515 return x.equals(y);
1516 }
1517
1519 template<class _tCon, typename _type>
1520 bool
1521 operator!=(const subscriptive_iterator<_tCon, _type>& x,
1522 const subscriptive_iterator<_tCon, _type>& y) ynothrow
1523 {
1524 return !(x == y);
1525 }
1527
1528 } // namespace ystdex;
1529
1530 #endif
1531
ystdex::subscriptive_iterator::value_type
_type value_type
Definition: iterator.hpp:1385
ystdex::pseudo_iterator::value
value_type value
Definition: iterator.hpp:363
ystdex::transformed_iterator::get_transformer
const transformer_type & get_transformer() const
Definition: iterator.hpp:616
ystdex::pair_iterator::value_type
typename traits_type::value_type value_type
Definition: iterator.hpp:843
ystdex::operator>=
bool operator>=(const path< _tSeqCon, _tNorm > &x, const path< _tSeqCon, _tNorm > &y)
Definition: path.hpp:400
ystdex::bitseg_iterator::pointer
byte * pointer
Definition: iterator.hpp:1177
ystdex::pair_iterator::operator=
pair_iterator & operator=(const pair_iterator &)=default
ystdex::pseudo_iterator::iterator_category
typename traits_type::iterator_category iterator_category
Definition: iterator.hpp:357
ystdex::bitseg_iterator::operator+=
bitseg_iterator & operator+=(difference_type n)
Definition: iterator.hpp:1204
ystdex::pseudo_iterator::operator--
pseudo_iterator operator--(int) const
Definition: iterator.hpp:447
ystdex::pair_iterator::pointer
typename traits_type::pointer pointer
Definition: iterator.hpp:845
ystdex::pointer_iterator::pointer_iterator
pointer_iterator(_tPointer &&ptr)
Definition: iterator.hpp:202
ystdex::bitseg_iterator::operator->
pointer operator->() const
Definition: iterator.hpp:1231
ystdex::bitseg_iterator::operator[]
reference operator[](difference_type n) const
Definition: iterator.hpp:1277
ystdex::indirect_input_iterator
间接输入迭代器。
Definition: iterator.hpp:1023
ystdex::bitseg_iterator::operator+
bitseg_iterator operator+(difference_type n) const
Definition: iterator.hpp:1286
ystdex::pair_iterator::operator++
pair_iterator & operator++()
Definition: iterator.hpp:913
ystdex::pointer_iterator::operator+=
pointer_iterator & operator+=(difference_type n)
Definition: iterator.hpp:210
ynothrowv
#define ynothrowv
YSLib 无异常抛出保证验证：有条件地使用无异常抛出规范。
Definition: ydef.h:494
ystdex::pointer_iterator
指针迭代器。
Definition: iterator.hpp:178
ystdex::bitseg_iterator::operator==
bool operator==(const bitseg_iterator< _vN, _bEndian > &x, const bitseg_iterator< _vN, _bEndian > &y)
Definition: iterator.hpp:1318
ystdex::iterator_transformation::first
static auto first(const _tIterator &i) -> decltype((i->first))
Definition: iterator.hpp:759
ystdex::pseudo_iterator::reference
typename traits_type::reference reference
Definition: iterator.hpp:361
ystdex::subscriptive_iterator::operator*
reference operator*() const
Definition: iterator.hpp:1419
ystdex::transformed_iterator
转换迭代器。
Definition: iterator.hpp:514
ystdex::indirect_input_iterator::pointer
typename std::iterator_traits< iterator_type >::pointer pointer
Definition: iterator.hpp:1031
ystdex::operator!=
bool operator!=(nullptr_t lhs, const _type &rhs)
Definition: ydef.h:638
ystdex::transformed_iterator::reference
decltype(std::declval< transformed_type >()) reference
Definition: iterator.hpp:530
ystdex::subscriptive_iterator::index
size_t index() const
Definition: iterator.hpp:1498
ystdex::pointer_iterator::operator-
pointer_iterator operator-(difference_type n) const
Definition: iterator.hpp:285
ystdex::pseudo_iterator::pseudo_iterator
pseudo_iterator(value_type v)
Definition: iterator.hpp:370
ystdex::pointer_classify::type
_type type
Definition: iterator.hpp:331
ystdex::bitseg_iterator::bitseg_iterator
bitseg_iterator(byte *p={}, unsigned char n=0)
构造：使用基指针和偏移位。
Definition: iterator.hpp:1197
ystdex::make_move_iterator_pair
auto make_move_iterator_pair(_tIterator1 it1, _tIterator2 it2) -> decltype(std::make_pair(std::make_move_iterator(it1), std::make_move_iterator(it2)))
取转移迭代器对。
Definition: iterator.hpp:146
ystdex::result_of_t
typename result_of< _type >::type result_of_t
Definition: type_op.hpp:286
ystdex::bitseg_iterator::operator--
bitseg_iterator operator--(int)
Definition: iterator.hpp:1268
ystdex::pointer_iterator::operator--
pointer_iterator & operator--()
Definition: iterator.hpp:255
ystdex::indirect_input_iterator::operator++
indirect_input_iterator & operator++()
迭代：向后遍历。
Definition: iterator.hpp:1104
ystdex::indirect_input_iterator::value_type
typename std::iterator_traits< iterator_type >::value_type value_type
Definition: iterator.hpp:1028
ystdex::pair_iterator::operator->
pointer operator->() const
Definition: iterator.hpp:907
ystdex::pseudo_iterator::pointer
typename traits_type::pointer pointer
Definition: iterator.hpp:360
ystdex::prev_if_eq
_tBi prev_if_eq(_tBi i, const _type &val, typename std::iterator_traits< _tBi >::difference_type n=1)
Definition: iterator.hpp:129
ystdex::pseudo_iterator::pseudo_iterator
pseudo_iterator()
Definition: iterator.hpp:366
ystdex::subscriptive_iterator
成员下标迭代器。
Definition: iterator.hpp:1380
ystdex::pointer_iterator::operator->
pointer operator->() const
Definition: iterator.hpp:235
ystdex::transformed_iterator::transformed_iterator
transformed_iterator()=default
ystdex::byte
unsigned char byte
字节类型。
Definition: ydef.h:555
ystdex::pair_iterator::operator++
pair_iterator operator++(int)
Definition: iterator.hpp:919
cassert.h
ISO C 断言/调试跟踪扩展。
ystdex::pointer_iterator::value_type
typename std::iterator_traits< iterator_type >::value_type value_type
Definition: iterator.hpp:184
ystdex::pair_iterator::pair_type
std::pair< _tMaster, _tSlave > pair_type
Definition: iterator.hpp:838
ystdex::pointer_iterator::operator==
bool operator==(const pointer_iterator< _type > &x, const pointer_iterator< _type > &y)
Definition: iterator.hpp:304
ystdex::subscriptive_iterator::operator+
subscriptive_iterator operator+(difference_type n) const
Definition: iterator.hpp:1469
ystdex::indirect_input_iterator::operator=
indirect_input_iterator & operator=(const indirect_input_iterator &)=default
ystdex::transformed_iterator::transformer_type
decay_t< _fTransformer > transformer_type
Definition: iterator.hpp:523
ystdex::indirect_input_iterator::operator!=
bool operator!=(const indirect_input_iterator< _tIterator > &x, const indirect_input_iterator< _tIterator > &y)
Definition: iterator.hpp:1143
ystdex::pseudo_iterator::operator->
pointer operator->() const
Definition: iterator.hpp:422
ystdex::indirect_input_iterator::operator++
indirect_input_iterator operator++(int)
Definition: iterator.hpp:1111
ystdex::decay_t
typename decay< _type >::type decay_t
Definition: type_op.hpp:271
ystdex::indirect_input_iterator::iterator_type
_tIterator iterator_type
Definition: iterator.hpp:1026
ystdex::get_first
const first_tag get_first
操纵子。
Definition: iterator.hpp:784
ystdex::bitseg_iterator::get_shift
size_t get_shift() const
Definition: iterator.hpp:1304
ystdex::pseudo_iterator::operator--
pseudo_iterator & operator--() const
满足双向迭代器要求。
Definition: iterator.hpp:442
ystdex::pointer_iterator::iterator_category
typename std::iterator_traits< iterator_type >::iterator_category iterator_category
Definition: iterator.hpp:183
ystdex::bitseg_iterator::operator-=
bitseg_iterator & operator-=(difference_type n)
Definition: iterator.hpp:1216
ystdex::pointer_iterator::operator--
pointer_iterator operator--(int)
Definition: iterator.hpp:262
ystdex::subscriptive_iterator::operator++
subscriptive_iterator & operator++()
Definition: iterator.hpp:1431
yforward
#define yforward(_expr)
根据参数类型使用 std::forward 传递对应参数。
Definition: ydef.h:722
ystdex::pseudo_iterator::operator[]
reference operator[](difference_type n) const
满足随机访问迭代器要求。
Definition: iterator.hpp:459
ystdex::pair_iterator::operator--
pair_iterator & operator--()
满足双向迭代器要求。
Definition: iterator.hpp:931
ystdex::transformed_iterator::operator==
bool operator==(const transformed_iterator< _type, _fTransformer > &x, const transformed_iterator< _type, _fTransformer > &y)
满足输入迭代器要求。
Definition: iterator.hpp:631
ystdex::get_indirect
const struct ystdex::indirect_tag get_indirect
yimpl
#define yimpl(...)
实现标签。
Definition: ydef.h:177
ystdex::bitseg_iterator::base
byte * base
Definition: iterator.hpp:1185
ystdex::bitseg_iterator::operator++
bitseg_iterator operator++(int)
Definition: iterator.hpp:1247
ystdex::subscriptive_iterator::operator-=
subscriptive_iterator & operator-=(difference_type n)
Definition: iterator.hpp:1409
ystdex::subscriptive_iterator::operator--
subscriptive_iterator operator--(int)
Definition: iterator.hpp:1452
ystdex::operator>
bool operator>(const path< _tSeqCon, _tNorm > &x, const path< _tSeqCon, _tNorm > &y)
Definition: path.hpp:393
ystdex::pair_iterator::pair_iterator
pair_iterator(const _tMaster &_i, const _tSlave &_s)
Definition: iterator.hpp:857
ystdex::transformed_iterator::transformer
transformer_type transformer
Definition: iterator.hpp:534
ystdex::subscriptive_iterator::difference_type
ptrdiff_t difference_type
Definition: iterator.hpp:1386
ystdex::pseudo_iterator::difference_type
typename traits_type::difference_type difference_type
Definition: iterator.hpp:359
ystdex::pseudo_iterator::traits_type
_tTraits traits_type
Definition: iterator.hpp:356
ystdex::pair_iterator::operator==
bool operator==(const pair_iterator< _tMaster, _tSlave > &x, const pair_iterator< _tMaster, _tSlave > &y)
Definition: iterator.hpp:999
ystdex::pointer_iterator::operator++
pointer_iterator & operator++()
Definition: iterator.hpp:241
ystdex::transformed_iterator::difference_type
typename pointer_classify< _tIterator >::type::difference_type difference_type
Definition: iterator.hpp:528
ystdex::subscriptive_iterator::container_type
_tCon container_type
Definition: iterator.hpp:1383
ystdex::swap
void swap(any &x, any &y)
交换对象。
Definition: any.h:729
ystdex::pseudo_iterator::operator=
pseudo_iterator & operator=(const pseudo_iterator &)=default
ystdex::pointer_iterator::raw
pointer raw
Definition: iterator.hpp:192
ystdex::indirect_input_iterator::indirect_input_iterator
indirect_input_iterator(indirect_input_iterator &&i)
Definition: iterator.hpp:1048
ystdex::get_value
const second_tag get_value
Definition: iterator.hpp:785
ystdex::bitseg_iterator::operator-
bitseg_iterator operator-(difference_type n) const
Definition: iterator.hpp:1292
ystdex::pseudo_iterator::operator+=
pseudo_iterator & operator+=(difference_type)
Definition: iterator.hpp:401
ystdex::pseudo_iterator::operator-
pseudo_iterator operator-(difference_type) const
Definition: iterator.hpp:471
ystdex::subscriptive_iterator::operator-
subscriptive_iterator operator-(difference_type n) const
Definition: iterator.hpp:1476
ystdex::pointer_iterator::operator+
pointer_iterator operator+(difference_type n) const
Definition: iterator.hpp:278
yunseq
#define yunseq
无序列依赖表达式组求值。
Definition: ydef.h:748
ystdex::pair_iterator::operator+=
pair_iterator & operator+=(difference_type n)
Definition: iterator.hpp:884
ystdex::pair_iterator::operator-
pair_iterator operator-(difference_type n) const
Definition: iterator.hpp:967
ystdex::pair_iterator::pair_iterator
pair_iterator()
Definition: iterator.hpp:849
ystdex::pseudo_iterator::operator+
pseudo_iterator operator+(difference_type) const
Definition: iterator.hpp:465
ystdex::pointer_iterator::iterator_type
_type * iterator_type
Definition: iterator.hpp:181
yassume
#define yassume
假定：环境语义。
Definition: cassert.h:58
ystdex::pointer_iterator::pointer
typename std::iterator_traits< iterator_type >::pointer pointer
Definition: iterator.hpp:187
ystdex::transformed_iterator::get
iterator_type & get()
取原迭代器引用。
Definition: iterator.hpp:593
ystdex::pair_iterator::operator-=
pair_iterator & operator-=(difference_type n)
Definition: iterator.hpp:892
ystdex::bitseg_iterator::seg_size
static const unsigned char seg_size
Definition: iterator.hpp:1181
ystdex::pair_iterator::operator+
pair_iterator operator+(difference_type n) const
Definition: iterator.hpp:958
ystdex::iterator_transformation::indirect
static auto indirect(const _tIterator &i) -> decltype((**i))
Definition: iterator.hpp:771
ystdex::bitseg_iterator::seg_n
static const unsigned char seg_n
Definition: iterator.hpp:1180
ynothrow
#define ynothrow
YSLib 无异常抛出保证：若支持 noexcept 关键字， 指定特定的 noexcept 异常规范。
Definition: ydef.h:514
ystdex::pair_iterator::difference_type
typename traits_type::difference_type difference_type
Definition: iterator.hpp:844
ystdex::indirect_input_iterator::operator->
pointer operator->() const
Definition: iterator.hpp:1071
ystdex::nullptr_t
空指针类。
Definition: ydef.h:583
ystdex::bitseg_iterator::value
byte value
Definition: iterator.hpp:1187
ystdex::pseudo_iterator::operator-=
pseudo_iterator & operator-=(difference_type)
Definition: iterator.hpp:408
ystdex::pseudo_iterator::iterator_type
_tIterator iterator_type
Definition: iterator.hpp:354
YSLib::Drawing::operator+
yconstfn GBinaryGroup< _type > operator+(const GBinaryGroup< _type > &a, const GBinaryGroup< _type > &b) ynothrow
加法：屏幕二元组。
Definition: ygdibase.h:203
ystdex::pointer_iterator::operator*
reference operator*() const
Definition: iterator.hpp:228
ystdex::n_tag< 0 >
Definition: type_op.hpp:788
ystdex::subscriptive_iterator::iterator_category
std::random_access_iterator_tag iterator_category
Definition: iterator.hpp:1384
ystdex::indirect_input_iterator::operator*
reference operator*() const
间接操作。
Definition: iterator.hpp:1093
yconstraint
#define yconstraint
约束：接口语义。
Definition: cassert.h:47
ystdex::array_ref_decay::type
typename array_decay< _type >::type type
Definition: type_op.hpp:739
ystdex::pair_iterator::reference
typename traits_type::reference reference
Definition: iterator.hpp:846
ystdex::pseudo_iterator::operator==
bool operator==(const pseudo_iterator< _type, _tIterator, _tTraits > &x, const pseudo_iterator< _type, _tIterator, _tTraits > &y)
满足输入迭代器要求。
Definition: iterator.hpp:486
ystdex::pointer_iterator::pointer_iterator
pointer_iterator(nullptr_t={})
Definition: iterator.hpp:196
ystdex::subscriptive_iterator::operator[]
reference operator[](difference_type n) const
Definition: iterator.hpp:1462
ystdex::pointer_iterator::reference
typename std::iterator_traits< iterator_type >::reference reference
Definition: iterator.hpp:188
ystdex::subscriptive_iterator::reference
_type & reference
Definition: iterator.hpp:1388
ystdex::subscriptive_iterator::operator+=
subscriptive_iterator & operator+=(difference_type n)
Definition: iterator.hpp:1402
ystdex::pseudo_iterator::value_type
typename traits_type::value_type value_type
Definition: iterator.hpp:358
ystdex::pair_iterator::traits_type
_tTraits traits_type
Definition: iterator.hpp:841
ystdex::subscriptive_iterator::pointer
_type * pointer
Definition: iterator.hpp:1387
yconstfn
#define yconstfn
指定编译时常量函数。
Definition: ydef.h:463
YSLib::UI::f
_tWidget _fCallable && f
Definition: ywgtevt.h:597
ystdex::subscriptive_iterator::operator--
subscriptive_iterator operator--()
Definition: iterator.hpp:1446
ystdex::exclude_self_ctor_t
enable_if_t<!is_same< _tClass &, remove_rcv_t< _tParam > & >::value, _type > exclude_self_ctor_t
移除选择类类型的特定重载避免构造模板和复制/转移构造函数冲突。
Definition: type_op.hpp:766
ystdex::indirect_input_iterator::difference_type
typename std::iterator_traits< iterator_type >::difference_type difference_type
Definition: iterator.hpp:1030
ystdex::bitseg_iterator::operator*
reference operator*() const
Definition: iterator.hpp:1223
ystdex::pair_iterator::pair_iterator
pair_iterator(const _tMaster &_i)
Definition: iterator.hpp:853
ystdex::bitseg_iterator::seg_width
static const unsigned char seg_width
Definition: iterator.hpp:1182
ystdex::indirect_input_iterator::iter
iterator_type iter
Definition: iterator.hpp:1035
ystdex::pair_iterator::operator[]
reference operator[](difference_type n) const
满足随机访问迭代器要求。
Definition: iterator.hpp:952
ystdex::pair_iterator::iterator_type
_tMaster iterator_type
Definition: iterator.hpp:839
ystdex::subscriptive_iterator::operator->
pointer operator->() const
Definition: iterator.hpp:1425
ystdex::transformed_iterator::operator[]
enable_if_t< is_convertible< decltype(std::declval< iterator_type & >)[_tDiff()]), reference >::value, reference > operator[](_tDiff n)
Definition: iterator.hpp:563
ystdex::subscriptive_iterator::operator!=
bool operator!=(const subscriptive_iterator< _tCon, _type > &x, const subscriptive_iterator< _tCon, _type > &y)
比较成员下标迭代器的不等性。
Definition: iterator.hpp:1521
ystdex::transformed_iterator::transformed_iterator
transformed_iterator(_tIter &&i, _tTran f={})
Definition: iterator.hpp:543
ystdex::pair_iterator::base
const pair_type & base() const
Definition: iterator.hpp:986
ystdex::subscriptive_iterator::operator++
subscriptive_iterator operator++(int)
Definition: iterator.hpp:1437
ystdex::pointer_iterator::operator-=
pointer_iterator & operator-=(difference_type n)
Definition: iterator.hpp:219
ystdex::pointer_iterator::operator[]
reference operator[](difference_type n) const
Definition: iterator.hpp:269
ystdex::indirect_input_iterator::reference
typename std::iterator_traits< iterator_type >::reference reference
Definition: iterator.hpp:1032
yconstexpr
#define yconstexpr
指定编译时常量表达式。
Definition: ydef.h:462
ystdex::is_undereferenceable
bool is_undereferenceable(const any_input_iterator< _type, _tDifference, _tPointer, _tReference > &i)
Definition: any_iterator.hpp:364
ystdex::enable_for_iterator_t
enable_if_t< is_same< decltype(++std::declval< _tParam & >()), _tParam & >::value, int > enable_for_iterator_t
选择迭代器类型的特定重载避免和其它类型冲突。
Definition: iterator.hpp:60
ystdex::pseudo_iterator
伪迭代器。
Definition: iterator.hpp:351
ystdex::pseudo_iterator::operator++
pseudo_iterator & operator++()
Definition: iterator.hpp:428
ystdex::pair_iterator::operator*
reference operator*() const
满足前向迭代器要求。
Definition: iterator.hpp:901
ystdex::pair_iterator::iterator_category
typename traits_type::iterator_category iterator_category
Definition: iterator.hpp:842
type_op.hpp
C++ 类型操作。
ystdex::pseudo_iterator::operator++
pseudo_iterator operator++(int)
Definition: iterator.hpp:433
ystdex::bitseg_iterator::difference_type
ptrdiff_t difference_type
Definition: iterator.hpp:1176
ystdex::bitseg_iterator::operator--
bitseg_iterator & operator--()
Definition: iterator.hpp:1256
ystdex::transformed_iterator::iterator_type
typename pointer_classify< remove_reference_t< _tIterator >>::type iterator_type
原迭代器类型。
Definition: iterator.hpp:522
ystdex::transformed_iterator::transformed_type
result_of_t< _fTransformer &(_tIterator &)> transformed_type
Definition: iterator.hpp:525
ystdex::indirect_input_iterator::operator==
friend bool operator==(const indirect_input_iterator &x, const indirect_input_iterator &y)
Definition: iterator.hpp:1120
ystdex::indirect_input_iterator::indirect_input_iterator
indirect_input_iterator(iterator_type i)
Definition: iterator.hpp:1041
ystdex::subscriptive_iterator::idx
size_t idx
Definition: iterator.hpp:1393
ystdex::pair_iterator::pair_iterator
pair_iterator(pair_iterator &&_r)
Definition: iterator.hpp:863
ystdex::pair_iterator::operator--
pair_iterator operator--(int)
Definition: iterator.hpp:937
ystdex::bitseg_iterator::reference
byte & reference
Definition: iterator.hpp:1178
ystdex::operator|
auto operator|(_tIterator &&i, first_tag) -> decltype(make_transform(std::forward< decltype(i)>(i), iterator_transformation::first< typename array_ref_decay< _tIterator >::type >))
管道匹配操作符。
Definition: iterator.hpp:797
ystdex::indirect_tag
Definition: iterator.hpp:787
ystdex::indirect_input_iterator::iterator_category
std::input_iterator_tag iterator_category
Definition: iterator.hpp:1027
ystdex::transformed_iterator::operator+=
transformed_iterator< _type, _fTransformer > & operator+=(transformed_iterator< _type, _fTransformer > &i, typename transformed_iterator< _type, _fTransformer >::difference_type n)
满足随机迭代器要求。
Definition: iterator.hpp:654
ystdex::pointer_classify
指针包装为类类型迭代器。
Definition: iterator.hpp:329
ystdex::transformed_iterator::make_transform
transformed_iterator< typename array_ref_decay< _tIterator >::type, _fTransformer > make_transform(_tIterator &&i, _fTransformer f)
创建转换迭代器。
Definition: iterator.hpp:742
CHRLib::c
c
Definition: chrproc.h:76
ystdex::next_if
_tIn next_if(_tIn i, _fPred f, typename std::iterator_traits< _tIn >::difference_type n=1)
迭代器指向的值满足条件时取邻接迭代器，否则取原值。
Definition: iterator.hpp:99
ystdex::bitseg_iterator::operator++
bitseg_iterator & operator++()
Definition: iterator.hpp:1237
ystdex::subscriptive_iterator::equals
bool equals(const subscriptive_iterator< _tCon, _type > &i) const
Definition: iterator.hpp:1491
ystdex::get_key
const first_tag get_key
Definition: iterator.hpp:784
ystdex::subscriptive_iterator::con_ptr
_tCon * con_ptr
Definition: iterator.hpp:1392
ystdex::iterator_transformation::second
static auto second(const _tIterator &i) -> decltype((i->second))
Definition: iterator.hpp:765
ystdex::subscriptive_iterator::operator==
bool operator==(const subscriptive_iterator< _tCon, _type > &x, const subscriptive_iterator< _tCon, _type > &y)
比较成员下标迭代器的相等性。
Definition: iterator.hpp:1512
ystdex::transformed_iterator::operator*
reference operator*() const
Definition: iterator.hpp:554
ystdex::next_if_eq
_tIn next_if_eq(_tIn i, const _type &val, typename std::iterator_traits< _tIn >::difference_type n=1)
Definition: iterator.hpp:107
ystdex::transformed_iterator::get_transformer
transformer_type & get_transformer()
Definition: iterator.hpp:611
YSLib::Drawing::operator-
yconstfn GBinaryGroup< _type > operator-(const GBinaryGroup< _type > &a, const GBinaryGroup< _type > &b) ynothrow
减法：屏幕二元组。
Definition: ygdibase.h:214
ystdex::n_tag
自然数标记。
Definition: type_op.hpp:782
ystdex::pseudo_iterator::operator*
reference operator*() const
满足前向迭代器要求。
Definition: iterator.hpp:416
v
byte v
Definition: CharRenderer.cpp:73
ystdex::enable_if_t
typename enable_if< _bCond, _type >::type enable_if_t
Definition: type_op.hpp:274
ystdex::pointer_iterator::operator++
pointer_iterator operator++(int)
Definition: iterator.hpp:249
ystdex::bitseg_iterator
位段迭代器。
Definition: iterator.hpp:1167
ystdex::bitseg_iterator::shift
unsigned char shift
Definition: iterator.hpp:1186
ystdex::indirect_input_iterator::indirect_input_iterator
indirect_input_iterator()
Definition: iterator.hpp:1038
ystdex::subscriptive_iterator::container
_tCon * container() const
Definition: iterator.hpp:1484
ystdex::pair_iterator
成对迭代器。
Definition: iterator.hpp:835
ystdex::subscriptive_iterator::subscriptive_iterator
subscriptive_iterator(_tCon &c, size_t i)
Definition: iterator.hpp:1397
ystdex::prev_if
_tBi prev_if(_tBi i, _fPred f, typename std::iterator_traits< _tBi >::difference_type n=1)
迭代器指向的值满足条件时取反向邻接迭代器，否则取原值。
Definition: iterator.hpp:122
ystdex::get_second
const second_tag get_second
Definition: iterator.hpp:785
ystdex::pointer_iterator::difference_type
typename std::iterator_traits< iterator_type >::difference_type difference_type
Definition: iterator.hpp:186