YSTest: iterator.hpp 源文件

YSTest PreAlpha_b700_20160611 The YSLib Test Project

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

- 文件列表
- 文件成员

iterator.hpp
浏览该文件的文档.
1 /*
2 © 2011-2016 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 "pointer.hpp" // for "iterator_op.hpp", iterator_operators_t,
32 // std::iterator_traits, _t, pointer_classify, cond_t, and_,
33 // exclude_self_t, true_type, enable_if_inconvertible_t, *_tag,
34 // yassume, is_undereferenceable, yconstraint, random_access_iteratable;
35 #include "type_op.hpp" // for first_tag, second_tag, std::tuple,
36 // make_index_sequence, index_sequence, std::get;
37 #include "ref.hpp" // for lref;
38
39 namespace ystdex
40 {
41
60 template<typename _type, typename _tIter = const _type*,
61 typename _tTraits = std::iterator_traits<_tIter>>
62 class pseudo_iterator : public iterator_operators_t<
63 pseudo_iterator<_type, _tIter, _tTraits>, _tTraits>
64 {
65 public:
66 using iterator_type = _tIter;
68 using traits_type = _tTraits;
69 using iterator_category = typename traits_type::iterator_category;
70 using value_type = typename traits_type::value_type;
71 using difference_type = typename traits_type::difference_type;
72 using pointer = typename traits_type::pointer;
73 using reference = typename traits_type::reference;
74
75 value_type value;
76
77 yconstfn
78 pseudo_iterator() = default;
79 explicit yconstfn
80 pseudo_iterator(value_type v)
81 : value(v)
82 {}
83 yconstfn
84 pseudo_iterator(const pseudo_iterator&) = default;
85 yconstfn
86 #if YB_IMPL_MSCPP
87 pseudo_iterator(pseudo_iterator&& i)
89 : value(std::move(i.value))
90 {}
91 #else
92 pseudo_iterator(pseudo_iterator&&) = default;
93 #endif
94
95 pseudo_iterator&
96 operator=(const pseudo_iterator&) = default;
97 pseudo_iterator&
98 #if YB_IMPL_MSCPP
99 operator=(pseudo_iterator&& i)
101 {
102 value = std::move(i.value);
103 return *this;
104 }
105 #else
106 operator=(pseudo_iterator&&) = default;
107 #endif
108
110
111 pseudo_iterator&
112 operator+=(difference_type) ynothrow
113 {
114 return *this;
115 }
116
117 pseudo_iterator&
118 operator-=(difference_type) ynothrow
119 {
120 return *this;
121 }
122
124
125 reference
127 operator*() ynothrow
128 {
129 return value;
130 }
131 yconstfn reference
132 operator*() const ynothrow
133 {
134 return value;
135 }
136
137 yconstfn_relaxed pseudo_iterator&
138 operator++() ynothrow
139 {
140 return *this;
141 }
142
147 yconstfn_relaxed pseudo_iterator&
148 operator--() ynothrow
149 {
150 return *this;
151 }
153
155
156 friend yconstfn bool
157 operator==(const pseudo_iterator& x, const pseudo_iterator& y)
158 ynoexcept_spec(bool(x.value == y.value))
159 {
160 return x.value == y.value;
161 }
162
163 friend yconstfn bool
164 operator<(const pseudo_iterator& x, const pseudo_iterator& y)
165 ynoexcept_spec(bool(x.value < y.value))
166 {
167 return x.value < y.value;
168 }
169
170 friend yconstfn difference_type
171 operator-(const pseudo_iterator&, const pseudo_iterator&) ynothrow
172 {
173 return 0;
174 }
176 };
177
178
179 namespace details
180 {
181
183 template<typename _tIter, typename _fTrans, typename _tReference>
184 struct transit_traits
185 {
186 using iterator_type = _t<pointer_classify<_tIter>>;
187 using iterator_category
188 = typename std::iterator_traits<iterator_type>::iterator_category;
189 using transformed_type = result_of_t<_fTrans&(_tIter&)>;
190 using difference_type
191 = typename std::iterator_traits<iterator_type>::difference_type;
192 using reference
193 = cond_t<is_same<_tReference, void>, transformed_type, _tReference>;
198 using pointer = decay_t<reference>*;
199 };
200
201 } // namespace details;
202
203
215 template<typename _tIter, typename _fTrans, typename _tReference = void>
216 class transformed_iterator : public iterator_operators_t<transformed_iterator<
217 _tIter, _fTrans, _tReference>, details::transit_traits<_tIter, _fTrans,
218 _tReference>>, private totally_ordered<transformed_iterator<_tIter, _fTrans,
219 _tReference>, typename
220 details::transit_traits<_tIter, _fTrans, _tReference>::iterator_type>
221 {
223 static_assert(is_decayed<_tIter>(), "Invalid type found.");
225 static_assert(is_decayed<_fTrans>(), "Invalid type found.");
226
228 template<typename, typename, typename>
229 friend class transformed_iterator;
230
231 private:
233 using impl_traits
234 = details::transit_traits<_tIter, _fTrans, _tReference>;
235
236 public:
241 using iterator_type = typename impl_traits::iterator_type;
242 using transformer_type = _fTrans;
244
245 using iterator_category = typename impl_traits::iterator_category;
246 using value_type = typename impl_traits::transformed_type;
248 using transformed_type = typename impl_traits::transformed_type;
251 using difference_type = typename impl_traits::difference_type;
253 using pointer = typename impl_traits::pointer;
258 using reference = typename impl_traits::reference;
259
260 protected:
262 mutable transformer_type transformer;
263
264 private:
266 typename pointer_classify<_tIter>::type ptr;
267
268 public:
270 transformed_iterator() = default;
272 // TODO: Use multiple template parameters to simplify after CWG 1227
273 // resolved by C++14.
274 template<typename _tIter2, yimpl(typename
275 = and_<exclude_self_t<transformed_iterator, _tIter2, true_type>,
276 enable_if_inconvertible_t<_tIter2&&, transformed_iterator, true_type>>)>
277 explicit yconstfn
278 transformed_iterator(_tIter2&& i)
279 : transformer(), ptr(yforward(i))
280 {}
282 template<typename _tIter2, typename _fTrans2 = _fTrans,
283 yimpl(typename = exclude_self_t<transformed_iterator, _tIter2>)>
284 explicit yconstfn
285 transformed_iterator(_tIter2&& i, _fTrans2 f)
286 : transformer(f), ptr(yforward(i))
287 {}
289 template<typename _tIter2, typename _fTrans2, typename _tRef2,
290 yimpl(typename = enable_if_t<and_<is_constructible<_tIter,
291 const _tIter2&>, is_constructible<_fTrans, const _fTrans2&>>::value>)>
292 yconstfn
293 transformed_iterator(const transformed_iterator<_tIter2, _fTrans2, _tRef2>&
294 i)
295 : transformer(i.transformer), ptr(i.get())
296 {}
298 template<typename _tIter2, typename _fTrans2, typename _tRef2,
299 yimpl(typename = enable_if_t<and_<is_constructible<_tIter, _tIter2&&>,
300 is_constructible<_fTrans, _fTrans2&&>>::value>)>
301 yconstfn
302 transformed_iterator(transformed_iterator<_tIter2, _fTrans2, _tRef2>&& i)
303 : transformer(std::move(i.transformer)), ptr(i.get())
304 {}
306
307 transformed_iterator(const transformed_iterator&) = default;
308 #if YB_IMPL_MSCPP
309 transformed_iterator(transformed_iterator&& i)
311 : transformer(std::move(i.transformer))
312 {}
313 #else
314 transformed_iterator(transformed_iterator&&) = default;
315 #endif
316
317
319 transformed_iterator&
320 operator=(const transformed_iterator&) = default;
322 transformed_iterator&
323 operator=(transformed_iterator&&) = default;
324
326 friend transformed_iterator&
327 operator+=(transformed_iterator& i, difference_type n)
328 ynoexcept(noexcept(decltype(i)(i)) && noexcept(i.get() += n))
329 {
330 i.get() += n;
331 return i;
332 }
333
335 friend transformed_iterator&
336 operator-=(transformed_iterator& i, difference_type n)
337 ynoexcept(noexcept(decltype(i)(i)) && noexcept(i.get() -= n))
338 {
339 i.get() -= n;
340 return i;
341 }
342
344 reference
345 operator*() const
346 ynoexcept_spec(reference(std::declval<transformed_iterator&>().
347 transformer(std::declval<transformed_iterator&>().get())))
348 {
349 return transformer(get());
350 }
351
353 transformed_iterator&
354 operator++()
355 {
356 ++get();
357 return *this;
358 }
359
361 transformed_iterator&
362 operator--()
363 {
364 --get();
365 return *this;
366 }
367
369
370 #if !(YB_IMPL_GNUCPP && YB_IMPL_GNUCPP < 50000)
371 template<yimpl(typename = void)>
372 #endif
373 friend yconstfn bool
374 operator==(const transformed_iterator& x, const transformed_iterator& y)
375 ynoexcept_spec(bool(x.get() == y.get()))
376 {
377 return x.get() == y.get();
378 }
379 #if !(YB_IMPL_GNUCPP && YB_IMPL_GNUCPP < 50000)
380 template<yimpl(typename = void)>
381 #endif
382 friend yconstfn bool
383 operator==(const transformed_iterator& x, const iterator_type& y)
384 ynoexcept_spec(bool(x.get() == y))
385 {
386 return x.get() == y;
387 }
388
389 #if !(YB_IMPL_GNUCPP && YB_IMPL_GNUCPP < 50000)
390 template<yimpl(typename = void)>
391 #endif
392 friend yconstfn bool
393 operator<(const transformed_iterator& x, const transformed_iterator& y)
394 ynoexcept_spec(bool(x.get() < y.get()))
395 {
396 return bool(x.get() < y.get());
397 }
398 #if !(YB_IMPL_GNUCPP && YB_IMPL_GNUCPP < 50000)
399 template<yimpl(typename = void)>
400 #endif
401 friend yconstfn bool
402 operator<(const transformed_iterator& x, const iterator_type& y)
403 ynoexcept_spec(bool(x.get() < y))
404 {
405 return bool(x.get() < y);
406 }
407
408 #if !(YB_IMPL_GNUCPP && YB_IMPL_GNUCPP < 50000)
409 template<yimpl(typename = void)>
410 #endif
411 friend yconstfn difference_type
412 operator-(const transformed_iterator& x, const transformed_iterator& y)
413 ynoexcept_spec(difference_type(x.get() - y.get()))
414 {
415 return difference_type(x.get() - y.get());
416 }
417 #if !(YB_IMPL_GNUCPP && YB_IMPL_GNUCPP < 50000)
418 template<yimpl(typename = void)>
419 #endif
420 friend yconstfn difference_type
421 operator-(const transformed_iterator& x, const iterator_type& y)
422 ynoexcept_spec(difference_type(x.get() - y))
423 {
424 return difference_type(x.get() - y);
425 }
426 #if !(YB_IMPL_GNUCPP && YB_IMPL_GNUCPP < 50000)
427 template<yimpl(typename = void)>
428 #endif
429 friend yconstfn difference_type
430 operator-(const iterator_type& x, const transformed_iterator& y)
431 ynoexcept_spec(difference_type(x - y.get()))
432 {
433 return difference_type(x - y.get());
434 }
436
438
439 yconstfn_relaxed iterator_type&
441 get() ynothrow
442 {
443 return ptr;
444 }
445
447 yconstfn const iterator_type&
448 get() const ynothrow
449 {
450 return ptr;
451 }
453
455
456 yconstfn_relaxed transformer_type&
457 get_transformer() ynothrow
458 {
459 return transformer;
460 }
461 yconstfn const transformer_type&
462 get_transformer() const ynothrow
463 {
464 return transformer;
465 }
467 };
468
475 template<typename _tIter, typename _fTrans>
476 inline transformed_iterator<decay_t<_tIter>, _fTrans>
477 make_transform(_tIter&& i, _fTrans f)
478 {
479 return transformed_iterator<decay_t<_tIter>, _fTrans>(yforward(i), f);
480 }
481
482
487 namespace iterator_transformation
488 {
489
491
492 template<typename _tIter = void>
493 struct first
494 {
495 yconstfn auto
496 operator()(const _tIter& i) const -> decltype((i->first))
497 {
498 return i->first;
499 }
500 };
501
502 template<>
503 struct first<void>
504 {
505 template<typename _tIter>
506 yconstfn auto
507 operator()(const _tIter& i) const -> decltype((i->first))
508 {
509 return i->first;
510 }
511 };
512
513
514 template<typename _tIter = void>
515 struct get
516 {
517 yconstfn auto
518 operator()(const _tIter& i) const -> decltype((*i).get())
519 {
520 return (*i).get();
521 }
522 };
523
524 template<>
525 struct get<void>
526 {
527 template<typename _tIter>
528 yconstfn auto
529 operator()(const _tIter& i) const -> decltype((*i).get())
530 {
531 return (*i).get();
532 }
533 };
534
535
536 template<typename _tIter = void>
537 struct indirect
538 {
539 yconstfn auto
540 operator()(const _tIter& i) const -> decltype(**i)
541 {
542 return **i;
543 }
544 };
545
546 template<>
547 struct indirect<void>
548 {
549 template<typename _tIter>
550 yconstfn auto
551 operator()(const _tIter& i) const -> decltype(**i)
552 {
553 return **i;
554 }
555 };
556
557
558 template<typename _tIter = void>
559 struct second
560 {
561 yconstfn auto
562 operator()(const _tIter& i) const -> decltype((i->second))
563 {
564 return i->second;
565 }
566 };
567
568 template<>
569 struct second<void>
570 {
571 template<typename _tIter>
572 yconstfn auto
573 operator()(const _tIter& i) const -> decltype((i->second))
574 {
575 return i->second;
576 }
577 };
579
580 } // namespace iterator_transformation;
581
582
588 yconstexpr const first_tag get_first{}, get_key{};
589 yconstexpr const second_tag get_second{}, get_value{};
591 yconstexpr const struct get_indirect_t{} get_indirect{};
593 yconstexpr const struct get_get_t{} get_get{};
595
596
603 template<typename _tIter>
604 inline auto
605 operator|(_tIter&& i, first_tag) -> decltype(make_transform(yforward(i),
606 iterator_transformation::first<>()))
607 {
608 return make_transform(yforward(i), iterator_transformation::first<>());
609 }
610 template<typename _tIter>
611 inline auto
612 operator|(_tIter&& i, second_tag) -> decltype(make_transform(yforward(i),
613 iterator_transformation::second<>()))
614 {
615 return make_transform(yforward(i), iterator_transformation::second<>());
616 }
618 template<typename _tIter>
619 inline auto
620 operator|(_tIter&& i, get_indirect_t) -> decltype(make_transform(yforward(i),
621 iterator_transformation::indirect<>()))
622 {
623 return make_transform(yforward(i), iterator_transformation::indirect<>());
624 }
626 template<typename _tIter>
627 inline auto
628 operator|(_tIter&& i, get_get_t)
629 -> decltype(make_transform(yforward(i), iterator_transformation::get<>()))
630 {
631 return make_transform(yforward(i), iterator_transformation::get<>());
632 }
634
635
645 template<typename _tIter, class _tTraits = std::iterator_traits<_tIter>,
646 typename... _tSlaves>
647 class tuple_iterator : private std::tuple<_tIter, _tSlaves...>, public
648 iterator_operators_t<tuple_iterator<_tIter, _tTraits, _tSlaves...>,
649 _tTraits>
650 {
651 public:
652 using base_type = std::tuple<_tIter, _tSlaves...>;
653 using iterator_type = _tIter;
654 using traits_type = _tTraits;
655 using iterator_category = typename traits_type::iterator_category;
656 using value_type = typename traits_type::value_type;
657 using difference_type = typename traits_type::difference_type;
658 using pointer = typename traits_type::pointer;
659 using reference = typename traits_type::reference;
660
661 private:
662 using seq_type = make_index_sequence<std::tuple_size<base_type>::value>;
663
664 public:
665 yconstfn
666 tuple_iterator() = default;
667 explicit yconstfn
668 tuple_iterator(const _tIter& i)
669 : base_type(i, _tSlaves()...)
670 {}
671 template<typename... _tParams>
672 yconstfn
673 tuple_iterator(const _tIter& i, _tParams&&... args)
674 : base_type(i, yforward(args)...)
675 {}
676 yconstfn
677 tuple_iterator(const tuple_iterator&) = default;
678 yconstfn
679 tuple_iterator(tuple_iterator&&) = default;
680
681 tuple_iterator&
682 operator=(const tuple_iterator&) = default;
683 tuple_iterator&
684 operator=(tuple_iterator&&) = default;
685
686 tuple_iterator&
687 operator+=(difference_type n) ynoexcept_spec(
688 yimpl(std::declval<tuple_iterator&>().add(n, seq_type())))
689 {
690 add(n, seq_type());
691 return *this;
692 }
693
694 tuple_iterator&
695 operator-=(difference_type n) ynoexcept_spec(
696 yimpl(std::declval<tuple_iterator&>().subtract(n, seq_type())))
697 {
698 subtract(n, seq_type());
699 return *this;
700 }
701
703
704 yconstfn reference
705 operator*() const
706 ynoexcept_spec(reference(*std::declval<tuple_iterator&>().get()))
707 {
708 return *get();
709 }
710
711 tuple_iterator&
712 operator++()
713 ynoexcept_spec(yimpl(std::declval<tuple_iterator&>().inc(seq_type())))
714 {
715 inc(seq_type());
716 return *this;
717 }
719
721 tuple_iterator&
722 operator--()
723 ynoexcept_spec(yimpl(std::declval<tuple_iterator&>().dec(seq_type())))
724 {
725 dec(seq_type());
726 return *this;
727 }
728
729 friend bool
730 operator==(const tuple_iterator& x, const tuple_iterator& y)
731 ynoexcept_spec(bool(x.get() == y.get()))
732 {
733 return x.get() == y.get();
734 }
735
736 private:
737 template<size_t... _vSeq>
738 void
739 add(difference_type n, index_sequence<_vSeq...>)
740 ynoexcept_spec(yimpl(yunseq((void(
741 std::get<_vSeq>(std::declval<tuple_iterator&>().base()) += n), 0)...)))
742 {
743 yunseq((void(std::get<_vSeq>(base()) += n), 0)...);
744 }
745
746 public:
747 yconstfn_relaxed base_type&
748 base() ynothrow
749 {
750 return *this;
751 }
752 yconstfn const base_type&
753 base() const ynothrow
754 {
755 return *this;
756 }
757
758 private:
759 template<size_t... _vSeq>
760 void
761 dec(index_sequence<_vSeq...>) ynoexcept_spec(yimpl(yunseq((void(
762 --std::get<_vSeq>(std::declval<tuple_iterator&>().base())), 0)...)))
763 {
764 yunseq((void(--std::get<_vSeq>(base())), 0)...);
765 }
766
767 template<size_t... _vSeq>
768 void
769 inc(index_sequence<_vSeq...>) ynoexcept_spec(yimpl(yunseq((void(
770 ++std::get<_vSeq>(std::declval<tuple_iterator&>().base())), 0)...)))
771 {
772 yunseq((void(++std::get<_vSeq>(base())), 0)...);
773 }
774
775 public:
776 yconstfn_relaxed iterator_type&
777 get() ynothrow
778 {
779 return std::get<0>(base());
780 }
781 yconstfn const iterator_type&
782 get() const ynothrow
783 {
784 return std::get<0>(base());
785 }
786
787 private:
788 template<size_t... _vSeq>
789 void
790 subtract(difference_type n, index_sequence<_vSeq...>)
791 ynoexcept_spec(yimpl(yunseq((void(
792 std::get<_vSeq>(std::declval<tuple_iterator&>().base()) -= n), 0)...)))
793 {
794 yunseq((void(std::get<_vSeq>(base()) -= n), 0)...);
795 }
796 };
797
798
806 template<typename _tIter, typename _tSlave,
807 class _tTraits = std::iterator_traits<_tIter>>
808 using pair_iterator = tuple_iterator<_tIter, _tTraits, _tSlave>;
809
810
817 template<typename _tIter>
818 class indirect_input_iterator : public iterator_operators_t<
819 indirect_input_iterator<_tIter>, std::iterator_traits<_tIter>>
820 {
821 public:
822 using iterator_type = _tIter;
823 using iterator_category = std::input_iterator_tag;
824 using value_type = typename std::iterator_traits<iterator_type>::value_type;
825 using difference_type
826 = typename std::iterator_traits<iterator_type>::difference_type;
827 using pointer = typename std::iterator_traits<iterator_type>::pointer;
828 using reference = typename std::iterator_traits<iterator_type>::reference;
829
830 private:
831 iterator_type iter;
832
833 public:
834 indirect_input_iterator()
835 : iter()
836 {}
837 indirect_input_iterator(iterator_type i)
838 : iter(i)
839 {
840 ++*this;
841 }
842 indirect_input_iterator(const indirect_input_iterator&) = default;
844 indirect_input_iterator(indirect_input_iterator&& i) ynothrow
845 : iter()
846 {
847 using std::swap;
848
849 swap(iter, i.iter);
850 }
851
852 indirect_input_iterator&
853 operator=(const indirect_input_iterator&) = default;
854 indirect_input_iterator&
855 #if YB_IMPL_MSCPP
856 operator=(indirect_input_iterator&& i)
858 {
859 iter = std::move(i.iter);
860 return *this;
861 }
862 #else
863 operator=(indirect_input_iterator&&) = default;
864 #endif
865
871 reference
872 operator*() const
873 {
874 yassume(!is_undereferenceable(iter));
875 return **iter;
876 }
877
882 indirect_input_iterator&
883 operator++()
884 {
885 yassume(!is_undereferenceable(iter));
886 ++*iter;
887 return *this;
888 }
889
890 friend bool
891 operator==(const indirect_input_iterator& x,
892 const indirect_input_iterator& y)
893 {
894 return (!bool(x) && !bool(y)) || x.iter == y.iter;
895 }
896
898 explicit
899 operator bool() const
900 {
901 return !is_undereferenceable(iter) && !is_undereferenceable(*iter);
902 }
903
904 iterator_type&
905 get() ynothrow
906 {
907 return iter;
908 }
909 const iterator_type&
910 get() const ynothrow
911 {
912 return iter;
913 }
914 };
915
916
927 template<typename _tIter>
928 class transposed_iterator : public iterator_operators_t<
929 transposed_iterator<_tIter>, std::iterator_traits<_tIter>>
930 {
931 public:
932 using iterator_type = _tIter;
933 using iterator_category = std::random_access_iterator_tag;
934 using value_type = typename std::iterator_traits<iterator_type>::value_type;
935 using difference_type
936 = typename std::iterator_traits<iterator_type>::difference_type;
937 using pointer = typename std::iterator_traits<iterator_type>::pointer;
938 using reference = typename std::iterator_traits<iterator_type>::reference;
939 using size_type = make_unsigned_t<difference_type>;
940
941 private:
942 iterator_type iter;
943 size_type width, height, row, col;
944
945 public:
946 transposed_iterator() = default;
948
949 yconstfn
950 transposed_iterator(iterator_type i, size_type w, size_type h)
951 ynoexcept(and_<is_nothrow_copy_constructible<iterator_type>,
952 is_nothrow_copy_constructible<size_type>>())
953 : iter(i), width((yconstraint(w != 0), w)),
954 height((yconstraint(h != 0), h)), row(), col(w)
955 {}
956 yconstfn
957 transposed_iterator(iterator_type i, size_type w, size_type h,
958 size_type idx)
959 ynoexcept(and_<is_nothrow_copy_constructible<iterator_type>,
960 is_nothrow_copy_constructible<size_type>>())
961 : iter(i), width((yconstraint(w != 0), w)),
962 height((yconstraint(h != 0), h)),
963 row((yconstraint(!(w * h < idx)), idx % h)), col(idx / h)
964 {}
966 transposed_iterator(const transposed_iterator&) = default;
967 #if YB_IMPL_MSCPP
968 transposed_iterator(transposed_iterator&& i)
970 : iter(std::move(i.iter)), width(std::move(i.width)),
971 height(std::move(i.height)), row(std::move(i.row)),
972 col(std::move(i.col))
973 {}
974 #else
975 transposed_iterator(transposed_iterator&&) = default;
976 #endif
977
978
979 transposed_iterator&
980 operator=(const transposed_iterator&) = default;
981 transposed_iterator&
982 operator=(transposed_iterator&&) = default;
983
984 transposed_iterator&
985 operator+=(difference_type n)
986 {
987 auto idx(col * height + row);
988
989 // NOTE: See $2015-02 @ %Documentation::Workflow::Annual2015.
990 yassume(!(difference_type(idx) < -n)),
991 yassume(!(difference_type(width * height) < difference_type(idx) + n));
992 idx += size_type(n);
993 yunseq(row = idx % height, col = idx / height);
994 return *this;
995 }
996
997 transposed_iterator&
998 operator-=(difference_type n)
999 {
1000 return *this += -n;
1001 }
1002
1003 reference
1004 operator*() const
1005 {
1006 yconstraint(!is_undereferenceable(*this));
1007 return *get();
1008 }
1009
1010 transposed_iterator&
1011 operator++()
1012 {
1013 yconstraint(!is_undereferenceable(*this));
1014 if(++row == height)
1015 yunseq(row = 0, ++col);
1016 return *this;
1017 }
1018
1019 transposed_iterator&
1020 operator--()
1021 {
1022 yconstraint(row != 0 || col != 0);
1023 if(row-- == 0)
1024 yunseq(row = height - 1, --col);
1025 return *this;
1026 }
1027
1029 friend bool
1030 operator==(const transposed_iterator& x, const transposed_iterator& y)
1031 {
1032 yconstraint(x.share_sequence(y));
1033
1034 return x.iter == y.iter && x.get_index() == y.get_index();
1035 }
1036
1037 friend bool
1038 operator<(const transposed_iterator& x, const transposed_iterator& y)
1039 {
1040 yconstraint(x.share_sequence(y));
1041 return x.row < y.row || (x.row == y.row && x.col < y.col);
1042 }
1043
1044 friend difference_type
1045 operator-(const transposed_iterator& x, const transposed_iterator& y)
1046 {
1047 yconstraint(x.share_sequence(y));
1048 // XXX: Conversion to 'difference_type' might be implementation-defined.
1049 return difference_type((x.col - y.col) * x.height + x.row - y.row);
1050 }
1051
1052 yconstfn const iterator_type&
1053 base() const ynothrow
1054 {
1055 return iter;
1056 }
1057
1058 iterator_type
1059 get() const ynothrowv
1060 {
1061 ynoexcept_assert("Invalid type found.", iter + row * width + col);
1062
1063 // XXX: Conversion to 'difference_type' might be implementation-defined.
1064 return iter + difference_type(get_index());
1065 }
1066
1067 friend bool
1068 is_undereferenceable(const transposed_iterator& i) ynothrow
1069 {
1070 using ystdex::is_undereferenceable;
1071
1072 return is_undereferenceable(i.iter)
1073 || !(i.row < i.height && i.col < i.width);
1074 }
1075
1076 yconstfn size_type
1077 get_column() const ynothrow
1078 {
1079 return col;
1080 }
1081
1082 yconstfn size_type
1083 get_height() const ynothrow
1084 {
1085 return height;
1086 }
1087
1088 yconstfn size_type
1089 get_index() const ynothrowv
1090 {
1091 ynoexcept_assert("Invalid type found.", row * width + col);
1092
1093 return row * width + col;
1094 }
1095
1096 yconstfn size_type
1097 get_row() const ynothrow
1098 {
1099 return row;
1100 }
1101
1102 yconstfn size_type
1103 get_width() const ynothrow
1104 {
1105 return width;
1106 }
1107
1108 bool
1109 share_sequence(const transposed_iterator& i) const ynothrow
1110 {
1111 yassume(!is_undereferenceable(*this)
1112 || (row == 0 && col == width)),
1113 yassume(!is_undereferenceable(i)
1114 || (i.row == 0 && i.col == i.width));
1115 return iter == i.iter && width == i.width && height == i.height;
1116 }
1117 };
1118
1125 template<typename _tIter, typename _tSize = make_unsigned_t<
1126 typename std::iterator_traits<decay_t<_tIter>>::difference_type>>
1127 inline transposed_iterator<decay_t<_tIter>>
1128 make_transposed(_tIter&& i, _tSize w, _tSize h)
1129 {
1130 return transposed_iterator<decay_t<_tIter>>(yforward(i), w, h);
1131 }
1132 template<typename _tIter, typename _tSize = make_unsigned_t<
1133 typename std::iterator_traits<decay_t<_tIter>>::difference_type>,
1134 typename _tIndex = _tSize>
1135 inline transposed_iterator<decay_t<_tIter>>
1136 make_transposed(_tIter&& i, _tSize w, _tSize h, _tIndex idx)
1137 {
1138 return transposed_iterator<decay_t<_tIter>>(yforward(i), w, h, idx);
1139 }
1141
1142
1148 template<typename _type, typename _fUpdater>
1149 class prototyped_iterator : public iterator_operators_t<
1150 prototyped_iterator<_type, _fUpdater>, std::iterator_traits<yimpl(_type*)>>
1151 {
1152 public:
1153 using updater_type = _fUpdater;
1154 using iterator_category = std::random_access_iterator_tag;
1155 using value_type = _type;
1156 using difference_type = ptrdiff_t;
1157 using pointer = _type*;
1158 using reference = _type&;
1159
1160 protected:
1162 lref<value_type> proto_ref;
1163 size_t idx;
1164 updater_type updater;
1165
1166 public:
1167 template<typename _fCallable>
1168 yconstfn
1169 prototyped_iterator(value_type& proto, size_t i, _fCallable&& f)
1170 : proto_ref(proto), idx(i), updater(yforward(f))
1171 {}
1172
1173 prototyped_iterator&
1174 operator+=(difference_type n)
1175 {
1176 idx += n;
1177 return *this;
1178 }
1179
1180 prototyped_iterator&
1181 operator-=(difference_type n)
1182 {
1183 yassume(!(idx < n));
1184 idx -= n;
1185 return *this;
1186 }
1187
1188 reference
1189 operator*() const
1190 {
1191 updater(proto_ref.get(), idx);
1192 return proto_ref;
1193 }
1194
1195 prototyped_iterator&
1196 operator++() ynothrow
1197 {
1198 ++idx;
1199 return *this;
1200 }
1201
1202 prototyped_iterator
1203 operator--() ynothrow
1204 {
1205 --idx;
1206 return *this;
1207 }
1208
1210 friend bool
1211 operator==(const prototyped_iterator& x, const prototyped_iterator& y)
1212 ynothrow
1213 {
1214 return std::addressof(x.proto_ref.get())
1215 == std::addressof(y.proto_ref.get()) && x.idx == y.idx;
1216 }
1217 };
1218
1225 template<typename _type, typename _fUpdater>
1226 yconstfn prototyped_iterator<_type, _fUpdater>
1227 make_prototyped_iterator(_type& proto, size_t i, _fUpdater f)
1228 {
1229 return prototyped_iterator<_type, _fUpdater>(proto, i, f);
1230 }
1231
1232
1241 template<class _tCon, typename _type, typename _tDifference = ptrdiff_t,
1242 typename _tPointer = _type*, typename _tReference = _type&>
1243 class subscriptive_iterator : public random_access_iteratable<
1244 subscriptive_iterator<_tCon, _type, _tDifference, _tPointer, _type>,
1245 _tDifference, _tReference>
1246 {
1247 public:
1249
1250 using container_type = _tCon;
1251 using iterator_category = std::random_access_iterator_tag;
1252 using value_type = _type;
1253 using difference_type = _tDifference;
1254 using pointer = _tPointer;
1255 using reference = _tReference;
1257
1258 protected:
1259 _tCon* container_ptr = {};
1260 size_t index = size_t(-1);
1261
1262 public:
1267 subscriptive_iterator() = default;
1269 yconstfn
1270 subscriptive_iterator(container_type& c, size_t i) ynothrowv
1271 : container_ptr(std::addressof(c)), index(i)
1272 {}
1273
1275
1276 subscriptive_iterator&
1277 operator+=(difference_type n) ynothrowv
1278 {
1279 index += n;
1280 return *this;
1281 }
1282
1283 subscriptive_iterator&
1284 operator-=(difference_type n) ynothrowv
1285 {
1286 yassume(!(index < n));
1287 index -= n;
1288 return *this;
1289 }
1291
1293
1294 reference
1295 operator*() const ynothrowv
1296 {
1297 yassume(!is_undereferenceable(*this));
1298 return (*container_ptr)[index];
1299 }
1300
1301 subscriptive_iterator&
1302 operator++() ynothrow
1303 {
1304 ++index;
1305 return *this;
1306 }
1307
1308 subscriptive_iterator
1309 operator--() ynothrow
1310 {
1311 --index;
1312 return *this;
1313 }
1315
1317 friend bool
1318 operator==(const subscriptive_iterator& x, const subscriptive_iterator& y)
1319 ynothrow
1320 {
1321 yconstraint(x.container() == y.container());
1322 return is_undereferenceable(y) || x.index == y.index;
1323 }
1324
1326 friend bool
1327 operator<(const subscriptive_iterator& x, const subscriptive_iterator& y)
1328 ynothrow
1329 {
1330 yconstraint(x.container() == y.container());
1331 return x.index < y.index;
1332 }
1333
1335 friend _tDifference
1336 operator-(const subscriptive_iterator& x, const subscriptive_iterator& y)
1337 ynothrow
1338 {
1339 yconstraint(x.container_ptr == y.container_ptr);
1340 return _tDifference(x.index - y.index);
1341 }
1342
1344 yconstfn _tCon*
1345 container() const ynothrow
1346 {
1347 return container_ptr;
1348 }
1349
1350 yconstfn size_t
1351 get_index() const ynothrow
1352 {
1353 return index;
1354 }
1355
1357 friend bool
1358 is_undereferenceable(const subscriptive_iterator& i) ynothrow
1359 {
1360 return !i.container_ptr;
1361 }
1362 };
1363
1364 } // namespace ystdex;
1365
1366 #endif
1367
ystdex::prototyped_iterator::updater_type
_fUpdater updater_type
Definition: iterator.hpp:1153
ystdex::subscriptive_iterator::subscriptive_iterator
subscriptive_iterator()=default
ystdex::transposed_iterator::share_sequence
bool share_sequence(const transposed_iterator &i) const
Definition: iterator.hpp:1109
ystdex::subscriptive_iterator::iterator_category
std::random_access_iterator_tag iterator_category
Definition: iterator.hpp:1251
ystdex::transposed_iterator::get_column
size_type get_column() const
Definition: iterator.hpp:1077
YSLib::Drawing::GBinaryGroup::get
yconstfn _type & get(GBinaryGroup< _type > &val)
取分量。
Definition: YGDIBase.h:242
ystdex::transposed_iterator::operator==
friend bool operator==(const transposed_iterator &x, const transposed_iterator &y)
Definition: iterator.hpp:1030
ystdex::prototyped_iterator::pointer
_type * pointer
Definition: iterator.hpp:1157
yassume
#define yassume(_expr)
假定：环境语义。
Definition: cassert.h:99
ystdex::transformed_iterator::get_transformer
transformer_type & get_transformer()
Definition: iterator.hpp:457
ystdex::transformed_iterator::operator+=
friend transformed_iterator & operator+=(transformed_iterator &i, difference_type n)
Definition: iterator.hpp:327
ystdex::subscriptive_iterator::operator--
subscriptive_iterator operator--()
Definition: iterator.hpp:1309
ystdex::prototyped_iterator::proto_ref
lref< value_type > proto_ref
Definition: iterator.hpp:1162
YSLib::Drawing::x
The boundary is out of the const Rect SDst SPos x
Definition: YDraw.h:127
ystdex::details::transit_traits::transformed_type
result_of_t< _fTrans &(_tIter &)> transformed_type
Definition: iterator.hpp:189
YSLib::Drawing::w
The boundary is out of the const Rect SDst w
Definition: YDraw.h:127
ystdex::lref::get
_type & get() const
Definition: ref.hpp:107
ystdex::subscriptive_iterator::pointer
_tPointer pointer
Definition: iterator.hpp:1254
ystdex::tuple_iterator::traits_type
_tTraits traits_type
Definition: iterator.hpp:654
ystdex::transformed_iterator::operator-
friend difference_type operator-(const transformed_iterator &x, const transformed_iterator &y)
Definition: iterator.hpp:412
ystdex::prototyped_iterator::reference
_type & reference
Definition: iterator.hpp:1158
yconstexpr
#define yconstexpr
指定编译时常量表达式。
Definition: ydef.h:653
ystdex::pseudo_iterator::reference
typename traits_type::reference reference
Definition: iterator.hpp:73
ystdex::subscriptive_iterator::is_undereferenceable
friend bool is_undereferenceable(const subscriptive_iterator &i)
Definition: iterator.hpp:1358
ynothrow
#define ynothrow
YSLib 无异常抛出保证：若支持 noexcept 关键字， 指定特定的 noexcept 异常规范。
Definition: ydef.h:740
ystdex::prototyped_iterator::operator*
reference operator*() const
Definition: iterator.hpp:1189
ystdex::prototyped_iterator::operator++
prototyped_iterator & operator++()
Definition: iterator.hpp:1196
ystdex::tuple_iterator::tuple_iterator
tuple_iterator(const _tIter &i)
Definition: iterator.hpp:668
ystdex::pseudo_iterator::iterator_category
typename traits_type::iterator_category iterator_category
Definition: iterator.hpp:69
yconstraint
#define yconstraint(_expr)
约束：接口语义。
Definition: cassert.h:82
ystdex::subscriptive_iterator::get_index
size_t get_index() const
Definition: iterator.hpp:1351
ystdex::transposed_iterator::get_width
size_type get_width() const
Definition: iterator.hpp:1103
ystdex::indirect_input_iterator::indirect_input_iterator
indirect_input_iterator(indirect_input_iterator &&i)
Definition: iterator.hpp:844
ystdex::transformed_iterator::transformed_iterator
transformed_iterator(const transformed_iterator< _tIter2, _fTrans2, _tRef2 > &i)
Definition: iterator.hpp:293
ystdex::transposed_iterator::make_transposed
transposed_iterator< decay_t< _tIter > > make_transposed(_tIter &&i, _tSize w, _tSize h)
Definition: iterator.hpp:1128
ystdex::swap
void swap(container_adaptor< _tSeqCon > &x, container_adaptor< _tSeqCon > &y)
Definition: container.hpp:179
v
byte v
Definition: CharRenderer.cpp:75
ystdex::subscriptive_iterator::container
_tCon * container() const
Definition: iterator.hpp:1345
ystdex::tuple_iterator::dec
void dec(index_sequence< _vSeq... >)
Definition: iterator.hpp:761
ystdex::indirect_input_iterator::reference
typename std::iterator_traits< iterator_type >::reference reference
Definition: iterator.hpp:828
ystdex::get_value
const second_tag get_value
Definition: iterator.hpp:589
pointer.hpp
通用指针。
ystdex::transposed_iterator::transposed_iterator
transposed_iterator(iterator_type i, size_type w, size_type h)
Definition: iterator.hpp:950
ystdex::cpp2014::enable_if_t
typename enable_if< _bCond, _type >::type enable_if_t
Definition: type_traits.hpp:350
ystdex::details::ebases
Definition: operators.hpp:100
ystdex::indirect_input_iterator::iter
iterator_type iter
Definition: iterator.hpp:831
ystdex::subscriptive_iterator::container_ptr
_tCon * container_ptr
Definition: iterator.hpp:1259
ystdex::transformed_iterator::operator<
friend bool operator<(const transformed_iterator &x, const transformed_iterator &y)
Definition: iterator.hpp:393
ystdex::indirect_input_iterator::iterator_type
_tIter iterator_type
Definition: iterator.hpp:822
ystdex::pseudo_iterator::operator*
reference operator*()
满足前向迭代器要求。
Definition: iterator.hpp:127
ystdex::get_get_t
Definition: iterator.hpp:593
ystdex::transformed_iterator::operator-
friend difference_type operator-(const iterator_type &x, const transformed_iterator &y)
Definition: iterator.hpp:430
ystdex::details::transit_traits::difference_type
typename std::iterator_traits< iterator_type >::difference_type difference_type
Definition: iterator.hpp:191
ystdex::transformed_iterator::iterator_category
typename impl_traits::iterator_category iterator_category
Definition: iterator.hpp:245
ystdex::tuple_iterator::operator++
tuple_iterator & operator++()
Definition: iterator.hpp:712
ystdex::iterator_transformation::second::operator()
auto operator()(const _tIter &i) const -> decltype((i->second))
Definition: iterator.hpp:562
ystdex::transformed_iterator::operator==
friend bool operator==(const transformed_iterator &x, const iterator_type &y)
Definition: iterator.hpp:383
ystdex::pseudo_iterator::operator==
friend bool operator==(const pseudo_iterator &x, const pseudo_iterator &y)
Definition: iterator.hpp:157
ystdex::tuple_iterator::reference
typename traits_type::reference reference
Definition: iterator.hpp:659
ystdex::enable_if_inconvertible_t
enable_if_t<!is_convertible< _tFrom, _tTo >::value, _type > enable_if_inconvertible_t
Definition: type_traits.hpp:998
ystdex::prototyped_iterator::operator-=
prototyped_iterator & operator-=(difference_type n)
Definition: iterator.hpp:1181
ystdex::tuple_iterator::iterator_type
_tIter iterator_type
Definition: iterator.hpp:653
ystdex::subscriptive_iterator::container_type
_tCon container_type
Definition: iterator.hpp:1250
ystdex::transposed_iterator::width
size_type width
Definition: iterator.hpp:943
ystdex::subscriptive_iterator::operator-=
subscriptive_iterator & operator-=(difference_type n)
Definition: iterator.hpp:1284
ystdex::iterator_transformation::indirect::operator()
auto operator()(const _tIter &i) const -> decltype(**i)
Definition: iterator.hpp:540
ystdex::transformed_iterator::transformed_iterator
transformed_iterator(transformed_iterator< _tIter2, _fTrans2, _tRef2 > &&i)
Definition: iterator.hpp:302
ystdex::subscriptive_iterator::operator++
subscriptive_iterator & operator++()
Definition: iterator.hpp:1302
ystdex::tuple_iterator::iterator_category
typename traits_type::iterator_category iterator_category
Definition: iterator.hpp:655
ynothrowv
#define ynothrowv
YSLib 无异常抛出保证验证：有条件地使用无异常抛出规范。
Definition: ydef.h:760
ystdex::indirect_input_iterator::operator++
indirect_input_iterator & operator++()
迭代：向后遍历。
Definition: iterator.hpp:883
ystdex::get_get
const struct ystdex::get_get_t get_get
platform::size_t
YF_API size_t
Definition: FileIO.h:1262
ystdex::transposed_iterator::get_row
size_type get_row() const
Definition: iterator.hpp:1097
ystdex::transposed_iterator::operator-
friend difference_type operator-(const transposed_iterator &x, const transposed_iterator &y)
Definition: iterator.hpp:1045
ystdex::pseudo_iterator::pseudo_iterator
pseudo_iterator()=default
ref.hpp
引用包装。
ystdex::pseudo_iterator::traits_type
_tTraits traits_type
Definition: iterator.hpp:68
ystdex::n_tag
自然数标记。
Definition: type_op.hpp:313
ystdex::pseudo_iterator::operator+=
pseudo_iterator & operator+=(difference_type)
Definition: iterator.hpp:112
ystdex::transposed_iterator::pointer
typename std::iterator_traits< iterator_type >::pointer pointer
Definition: iterator.hpp:937
ystdex::transposed_iterator::get_index
size_type get_index() const
Definition: iterator.hpp:1089
ystdex::tuple_iterator::operator=
tuple_iterator & operator=(const tuple_iterator &)=default
ystdex::transformed_iterator::transformed_iterator
transformed_iterator(_tIter2 &&i, _fTrans2 f)
Definition: iterator.hpp:285
ystdex::pseudo_iterator::operator<
friend bool operator<(const pseudo_iterator &x, const pseudo_iterator &y)
Definition: iterator.hpp:164
ystdex::transposed_iterator::iterator_type
_tIter iterator_type
Definition: iterator.hpp:932
ystdex::tuple_iterator::value_type
typename traits_type::value_type value_type
Definition: iterator.hpp:656
ystdex::iterator_transformation::first< void >::operator()
auto operator()(const _tIter &i) const -> decltype((i->first))
Definition: iterator.hpp:507
ystdex::transformed_iterator::transformed_type
typename impl_traits::transformed_type transformed_type
Definition: iterator.hpp:249
ystdex::transposed_iterator::base
const iterator_type & base() const
Definition: iterator.hpp:1053
ystdex::transformed_iterator::value_type
typename impl_traits::transformed_type value_type
Definition: iterator.hpp:246
ystdex::details::transit_traits
Definition: iterator.hpp:184
ystdex::transposed_iterator::operator+=
transposed_iterator & operator+=(difference_type n)
Definition: iterator.hpp:985
ystdex::transformed_iterator::transformed_iterator
transformed_iterator(_tIter2 &&i)
Definition: iterator.hpp:278
ystdex::subscriptive_iterator::value_type
_type value_type
Definition: iterator.hpp:1252
ystdex::pseudo_iterator::operator*
reference operator*() const
Definition: iterator.hpp:132
ystdex::indirect_input_iterator::value_type
typename std::iterator_traits< iterator_type >::value_type value_type
Definition: iterator.hpp:824
ystdex::exclude_self_t
enable_if_t<!is_same< _tClass &, decay_t< _tParam > & >::value, _type > exclude_self_t
移除选择类类型的特定重载避免构造模板和复制/转移特殊成员函数冲突。
Definition: type_traits.hpp:708
CHRLib::c
c
Definition: CharacterProcessing.h:81
ystdex::is_decayed
判断指定类型是否已退化。
Definition: type_traits.hpp:866
ystdex::transposed_iterator::transposed_iterator
transposed_iterator()=default
ystdex::transformed_iterator::iterator_type
typename impl_traits::iterator_type iterator_type
原迭代器类型。
Definition: iterator.hpp:241
ystdex::transformed_iterator::operator++
transformed_iterator & operator++()
Definition: iterator.hpp:354
ystdex::get_key
const first_tag get_key
Definition: iterator.hpp:588
ystdex::tuple_iterator::add
void add(difference_type n, index_sequence< _vSeq... >)
Definition: iterator.hpp:739
ystdex::details::transit_traits::iterator_type
_t< pointer_classify< _tIter >> iterator_type
Definition: iterator.hpp:186
ystdex::prototyped_iterator::idx
size_t idx
Definition: iterator.hpp:1163
ystdex::subscriptive_iterator::operator-
friend _tDifference operator-(const subscriptive_iterator &x, const subscriptive_iterator &y)
Definition: iterator.hpp:1336
ystdex::lref< value_type >
yimpl
#define yimpl(...)
实现标签。
Definition: ydef.h:256
ystdex::subscriptive_iterator::reference
_tReference reference
Definition: iterator.hpp:1255
ystdex::subscriptive_iterator::operator==
friend bool operator==(const subscriptive_iterator &x, const subscriptive_iterator &y)
Definition: iterator.hpp:1318
ystdex::iterator_transformation::get< void >::operator()
auto operator()(const _tIter &i) const -> decltype((*i).get())
Definition: iterator.hpp:529
ystdex::transformed_iterator::transformer_type
_fTrans transformer_type
Definition: iterator.hpp:242
ystdex::tuple_iterator::get
iterator_type & get()
Definition: iterator.hpp:777
ystdex::transposed_iterator::row
size_type row
Definition: iterator.hpp:943
ystdex::indirect_input_iterator::iterator_category
std::input_iterator_tag iterator_category
Definition: iterator.hpp:823
ynoexcept_spec
#define ynoexcept_spec(...)
表达式 noexcept 异常规范。
Definition: ydef.h:768
ystdex::tuple_iterator::operator==
friend bool operator==(const tuple_iterator &x, const tuple_iterator &y)
Definition: iterator.hpp:730
ystdex::tuple_iterator::tuple_iterator
tuple_iterator()=default
ystdex::transposed_iterator::height
size_type height
Definition: iterator.hpp:943
ystdex::details::transit_traits::pointer
decay_t< reference > * pointer
Definition: iterator.hpp:198
ystdex::pseudo_iterator::value_type
typename traits_type::value_type value_type
Definition: iterator.hpp:70
ystdex::tuple_iterator::operator*
reference operator*() const
满足输入迭代器要求。
Definition: iterator.hpp:705
ynoexcept_assert
#define ynoexcept_assert(_msg,...)
表达式 noexcept 静态断言。
Definition: ydef.h:721
ystdex::pseudo_iterator::operator-=
pseudo_iterator & operator-=(difference_type)
Definition: iterator.hpp:118
ystdex::pseudo_iterator::operator=
pseudo_iterator & operator=(const pseudo_iterator &)=default
yconstfn_relaxed
#define yconstfn_relaxed
指定编译时没有 C++11 限制和隐式成员 const 的常量函数。
Definition: ydef.h:666
std
Definition: memory.hpp:1100
ystdex::get_second
const second_tag get_second
Definition: iterator.hpp:589
ystdex::iterator_transformation::first
Definition: iterator.hpp:493
ystdex::_t
typename _type::type _t
嵌套类型别名。
Definition: type_traits.hpp:96
ystdex::iterator_transformation::get
Definition: iterator.hpp:515
ystdex::transformed_iterator::pointer
typename impl_traits::pointer pointer
Definition: iterator.hpp:253
ystdex::tuple_iterator::base
base_type & base()
Definition: iterator.hpp:748
ystdex::tuple_iterator::operator+=
tuple_iterator & operator+=(difference_type n)
Definition: iterator.hpp:687
ystdex::transformed_iterator::transformed_iterator
transformed_iterator()=default
ystdex::transformed_iterator::get_transformer
const transformer_type & get_transformer() const
Definition: iterator.hpp:462
ystdex::transformed_iterator::ptr
pointer_classify< _tIter >::type ptr
Definition: iterator.hpp:266
ystdex::indirect_input_iterator::operator*
reference operator*() const
间接操作。
Definition: iterator.hpp:872
ystdex::get_indirect
const struct ystdex::get_indirect_t get_indirect
ystdex::transposed_iterator::transposed_iterator
transposed_iterator(iterator_type i, size_type w, size_type h, size_type idx)
Definition: iterator.hpp:957
ystdex::subscriptive_iterator::operator*
reference operator*() const
Definition: iterator.hpp:1295
yunseq
#define yunseq
无序列依赖表达式组求值。
Definition: ydef.h:996
ystdex::prototyped_iterator::operator+=
prototyped_iterator & operator+=(difference_type n)
Definition: iterator.hpp:1174
ystdex::tuple_iterator::difference_type
typename traits_type::difference_type difference_type
Definition: iterator.hpp:657
ystdex::prototyped_iterator::operator==
friend bool operator==(const prototyped_iterator &x, const prototyped_iterator &y)
Definition: iterator.hpp:1211
ystdex::iterator_transformation::first::operator()
auto operator()(const _tIter &i) const -> decltype((i->first))
Definition: iterator.hpp:496
ystdex::iterator_operators_t
_t< details::iterator_operators< _tIter, _tTraits >> iterator_operators_t
按迭代器类别取可实现迭代器的重载操作符集合的实现。
Definition: iterator_op.hpp:191
ystdex::tuple_iterator::seq_type
make_index_sequence< std::tuple_size< base_type >::value > seq_type
Definition: iterator.hpp:662
ystdex
特性测试宏。
Definition: ydef.h:796
ystdex::pseudo_iterator::operator-
friend difference_type operator-(const pseudo_iterator &, const pseudo_iterator &)
Definition: iterator.hpp:171
ystdex::indirect_input_iterator::pointer
typename std::iterator_traits< iterator_type >::pointer pointer
Definition: iterator.hpp:827
ystdex::transposed_iterator::difference_type
typename std::iterator_traits< iterator_type >::difference_type difference_type
Definition: iterator.hpp:936
ystdex::tuple_iterator::operator-=
tuple_iterator & operator-=(difference_type n)
Definition: iterator.hpp:695
ystdex::transformed_iterator::reference
typename impl_traits::reference reference
Definition: iterator.hpp:258
ystdex::subscriptive_iterator::operator<
friend bool operator<(const subscriptive_iterator &x, const subscriptive_iterator &y)
Definition: iterator.hpp:1327
ystdex::subscriptive_iterator
成员下标迭代器。
Definition: iterator.hpp:1243
ystdex::transformed_iterator::operator-
friend difference_type operator-(const transformed_iterator &x, const iterator_type &y)
Definition: iterator.hpp:421
ystdex::cond_t
conditional_t< _tCond::value, _tThen, _tElse > cond_t
条件判断。
Definition: type_traits.hpp:698
ystdex::transformed_iterator::difference_type
typename impl_traits::difference_type difference_type
Definition: iterator.hpp:251
ystdex::operator|
auto operator|(_tIter &&i, first_tag) -> decltype(make_transform(std::forward< decltype(i)>(i), iterator_transformation::first<>()))
管道匹配操作符。
Definition: iterator.hpp:605
ystdex::subscriptive_iterator::operator+=
subscriptive_iterator & operator+=(difference_type n)
Definition: iterator.hpp:1277
ystdex::transposed_iterator::get_height
size_type get_height() const
Definition: iterator.hpp:1083
ystdex::is_undereferenceable
bool is_undereferenceable(const _tIter &)
Definition: deref_op.hpp:45
ystdex::pseudo_iterator::value
value_type value
Definition: iterator.hpp:75
ystdex::n_tag< 0 >
Definition: type_op.hpp:319
ystdex::tuple_iterator::subtract
void subtract(difference_type n, index_sequence< _vSeq... >)
Definition: iterator.hpp:790
ystdex::iterator_transformation::indirect
Definition: iterator.hpp:537
ystdex::transformed_iterator::operator--
transformed_iterator & operator--()
Definition: iterator.hpp:362
ystdex::pseudo_iterator::difference_type
typename traits_type::difference_type difference_type
Definition: iterator.hpp:71
ystdex::pointer_classify
指针包装为类类型迭代器。
Definition: pointer.hpp:307
ystdex::transposed_iterator::operator=
transposed_iterator & operator=(const transposed_iterator &)=default
YSLib::UI::y
SPos SPos y
Definition: YWidget.cpp:44
ystdex::tuple_iterator::pointer
typename traits_type::pointer pointer
Definition: iterator.hpp:658
ystdex::transposed_iterator::operator++
transposed_iterator & operator++()
Definition: iterator.hpp:1011
YSLib::i
return i
Definition: YCoreUtilities.h:176
ystdex::transposed_iterator::iter
iterator_type iter
Definition: iterator.hpp:942
ystdex::tuple_iterator::base
const base_type & base() const
Definition: iterator.hpp:753
ystdex::transformed_iterator::make_transform
transformed_iterator< decay_t< _tIter >, _fTrans > make_transform(_tIter &&i, _fTrans f)
创建变换迭代器。
Definition: iterator.hpp:477
ystdex::prototyped_iterator::operator--
prototyped_iterator operator--()
Definition: iterator.hpp:1203
ystdex::transposed_iterator::iterator_category
std::random_access_iterator_tag iterator_category
Definition: iterator.hpp:933
ystdex::transposed_iterator::operator--
transposed_iterator & operator--()
Definition: iterator.hpp:1020
ystdex::transformed_iterator::operator-=
friend transformed_iterator & operator-=(transformed_iterator &i, difference_type n)
Definition: iterator.hpp:336
ynoexcept
#define ynoexcept(...)
YSLib 无异常抛出保证：指定特定的异常规范。
Definition: ydef.h:720
ystdex::cpp2014::make_unsigned_t
typename make_unsigned< _type >::type make_unsigned_t
Definition: type_traits.hpp:317
ystdex::indirect_input_iterator::difference_type
typename std::iterator_traits< iterator_type >::difference_type difference_type
Definition: iterator.hpp:826
ystdex::pseudo_iterator::operator--
pseudo_iterator & operator--()
满足双向迭代器要求。
Definition: iterator.hpp:148
ystdex::prototyped_iterator::make_prototyped_iterator
prototyped_iterator< _type, _fUpdater > make_prototyped_iterator(_type &proto, size_t i, _fUpdater f)
创建原型迭代器。
Definition: iterator.hpp:1227
yconstfn
#define yconstfn
指定编译时常量函数。
Definition: ydef.h:654
ystdex::transposed_iterator::operator<
friend bool operator<(const transposed_iterator &x, const transposed_iterator &y)
Definition: iterator.hpp:1038
ystdex::prototyped_iterator
原型迭代器：共享对象引用，在解引用时进行指定的更新操作的随机访问迭代器。
Definition: iterator.hpp:1149
ystdex::pseudo_iterator::pseudo_iterator
pseudo_iterator(value_type v)
Definition: iterator.hpp:80
type_op.hpp
C++ 类型操作。
ystdex::iterator_transformation::second
Definition: iterator.hpp:559
ystdex::get_first
const first_tag get_first
操纵子。
Definition: iterator.hpp:588
ystdex::tuple_iterator::base_type
std::tuple< _tIter, _tSlaves... > base_type
Definition: iterator.hpp:652
ystdex::iterator_transformation::second< void >::operator()
auto operator()(const _tIter &i) const -> decltype((i->second))
Definition: iterator.hpp:573
ystdex::subscriptive_iterator::difference_type
_tDifference difference_type
Definition: iterator.hpp:1253
ystdex::pseudo_iterator::pointer
typename traits_type::pointer pointer
Definition: iterator.hpp:72
ystdex::details::transit_traits::iterator_category
typename std::iterator_traits< iterator_type >::iterator_category iterator_category
Definition: iterator.hpp:188
ystdex::transposed_iterator::col
size_type col
Definition: iterator.hpp:943
ystdex::tuple_iterator::tuple_iterator
tuple_iterator(const _tIter &i, _tParams &&...args)
Definition: iterator.hpp:673
ystdex::prototyped_iterator::iterator_category
std::random_access_iterator_tag iterator_category
Definition: iterator.hpp:1154
yforward
#define yforward(_expr)
根据参数类型使用 std::forward 传递对应参数。
Definition: ydef.h:969
ystdex::transposed_iterator::reference
typename std::iterator_traits< iterator_type >::reference reference
Definition: iterator.hpp:938
ystdex::prototyped_iterator::value_type
_type value_type
Definition: iterator.hpp:1155
ystdex::transformed_iterator::operator*
reference operator*() const
Definition: iterator.hpp:345
ystdex::transposed_iterator::is_undereferenceable
friend bool is_undereferenceable(const transposed_iterator &i)
Definition: iterator.hpp:1068
ystdex::iterator_transformation::get::operator()
auto operator()(const _tIter &i) const -> decltype((*i).get())
Definition: iterator.hpp:518
ystdex::transformed_iterator::transformer
transformer_type transformer
Definition: iterator.hpp:262
ystdex::transformed_iterator::get
iterator_type & get()
取原迭代器引用。
Definition: iterator.hpp:441
ystdex::pseudo_iterator::iterator_type
_tIter iterator_type
Definition: iterator.hpp:66
ystdex::dep_ops::totally_ordered
details::flat_ops< _type, _type2, _tOpt, less_than_comparable, equality_comparable > totally_ordered
Definition: operators.hpp:367
YSLib::IO::f
const string &path const String &path _func f
Definition: YSLib/Service/FileSystem.h:430
ystdex::tuple_iterator::operator--
tuple_iterator & operator--()
满足双向迭代器要求。
Definition: iterator.hpp:722
ystdex::transposed_iterator::operator-=
transposed_iterator & operator-=(difference_type n)
Definition: iterator.hpp:998
ystdex::indirect_input_iterator::indirect_input_iterator
indirect_input_iterator(iterator_type i)
Definition: iterator.hpp:837
CHRLib::args
_tParams && args
Definition: CharacterProcessing.h:538
ystdex::pseudo_iterator
伪迭代器。
Definition: iterator.hpp:62
ystdex::indirect_input_iterator::operator=
indirect_input_iterator & operator=(const indirect_input_iterator &)=default
ystdex::indirect_input_iterator
间接输入迭代器。
Definition: iterator.hpp:818
ystdex::transposed_iterator
下标转置迭代器适配器。
Definition: iterator.hpp:928
ystdex::transposed_iterator::value_type
typename std::iterator_traits< iterator_type >::value_type value_type
Definition: iterator.hpp:934
ystdex::subscriptive_iterator::subscriptive_iterator
subscriptive_iterator(container_type &c, size_t i)
Definition: iterator.hpp:1270
ystdex::transformed_iterator::operator==
friend bool operator==(const transformed_iterator &x, const transformed_iterator &y)
Definition: iterator.hpp:374
ystdex::tuple_iterator::inc
void inc(index_sequence< _vSeq... >)
Definition: iterator.hpp:769
ystdex::iterator_transformation::indirect< void >::operator()
auto operator()(const _tIter &i) const -> decltype(**i)
Definition: iterator.hpp:551
ystdex::transposed_iterator::size_type
make_unsigned_t< difference_type > size_type
Definition: iterator.hpp:939
ystdex::and_
逻辑操作元函数。
Definition: type_traits.hpp:394
ystdex::indirect_input_iterator::operator==
friend bool operator==(const indirect_input_iterator &x, const indirect_input_iterator &y)
Definition: iterator.hpp:891
ystdex::transformed_iterator::operator=
transformed_iterator & operator=(const transformed_iterator &)=default
ystdex::prototyped_iterator::updater
updater_type updater
Definition: iterator.hpp:1164
ystdex::tuple_iterator
元组迭代器。
Definition: iterator.hpp:647
ystdex::prototyped_iterator::prototyped_iterator
prototyped_iterator(value_type &proto, size_t i, _fCallable &&f)
Definition: iterator.hpp:1169
platform::bool
std::FILE *fp bool
Definition: FileIO.h:1187
ystdex::transposed_iterator::operator*
reference operator*() const
Definition: iterator.hpp:1004
ystdex::pseudo_iterator::operator++
pseudo_iterator & operator++()
Definition: iterator.hpp:138
ystdex::get_indirect_t
Definition: iterator.hpp:591
ystdex::indirect_input_iterator::indirect_input_iterator
indirect_input_iterator()
Definition: iterator.hpp:834
ystdex::subscriptive_iterator::index
size_t index
Definition: iterator.hpp:1260
ystdex::prototyped_iterator::difference_type
ptrdiff_t difference_type
Definition: iterator.hpp:1156
platform::n
size_t n
Definition: YCLib/FileSystem.cpp:321
ystdex::details::transit_traits::reference
cond_t< is_same< _tReference, void >, transformed_type, _tReference > reference
Definition: iterator.hpp:193
ystdex::transformed_iterator
变换迭代器。
Definition: iterator.hpp:216