YSTest: iterator.hpp 源文件

YSTest PreAlpha_b800_20170810 The YSLib Test Project

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

- 文件列表
- 文件成员

iterator.hpp
浏览该文件的文档.
1 /*
2 © 2011-2017 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, enable_if_inconvertible_t, *_tag, yassume,
34 // 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 = remove_reference_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 = details::transit_traits<_tIter, _fTrans, _tReference>;
234
235 public:
240 using iterator_type = typename impl_traits::iterator_type;
241 using transformer_type = _fTrans;
243
244 using iterator_category = typename impl_traits::iterator_category;
245 using value_type = typename impl_traits::transformed_type;
247 using transformed_type = typename impl_traits::transformed_type;
250 using difference_type = typename impl_traits::difference_type;
252 using pointer = typename impl_traits::pointer;
257 using reference = typename impl_traits::reference;
258
259 protected:
261 mutable transformer_type transformer;
262
263 private:
265 iterator_type transformed;
266
267 public:
269 transformed_iterator() = default;
270 // XXX: This is not actually related to substitution order. For other cases,
271 // use of multiple template parameters to simplify after CWG 1227 resolved
272 // by C++14 may be necessary.
274 template<typename _tIter2,
275 yimpl(typename = exclude_self_t<transformed_iterator, _tIter2>,
276 typename = enable_if_convertible_t<_tIter2&&, iterator_type>)>
277 explicit yconstfn
278 transformed_iterator(_tIter2&& i)
279 : transformer(), transformed(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), transformed(yforward(i))
287 {}
289 template<typename _tIter2, typename _fTrans2, typename _tRef2,
290 yimpl(typename = enable_if_t<and_<not_<is_convertible<const
291 transformed_iterator<_tIter2, _fTrans2, _tRef2>&, iterator_type>>,
292 is_constructible<_tIter, const _tIter2&>,
293 is_constructible<_fTrans, const _fTrans2&>>::value>)>
294 yconstfn
295 transformed_iterator(
296 const transformed_iterator<_tIter2, _fTrans2, _tRef2>& i)
297 : transformer(i.transformer), transformed(i.get())
298 {}
300 template<typename _tIter2, typename _fTrans2, typename _tRef2,
301 yimpl(typename = enable_if_t<and_<not_<is_convertible<
302 transformed_iterator<_tIter2, _fTrans2, _tRef2>&&, iterator_type>>,
303 is_constructible<_tIter, _tIter2&&>,
304 is_constructible<_fTrans, _fTrans2&&>>::value>)>
305 yconstfn
306 transformed_iterator(transformed_iterator<_tIter2, _fTrans2, _tRef2>&& i)
307 : transformer(std::move(i.transformer)), transformed(i.get())
308 {}
310
311 transformed_iterator(const transformed_iterator&) = default;
312 #if YB_IMPL_MSCPP
313 transformed_iterator(transformed_iterator&& i)
315 : transformer(std::move(i.transformer))
316 {}
317 #else
318 transformed_iterator(transformed_iterator&&) = default;
319 #endif
320
321
323 transformed_iterator&
324 operator=(const transformed_iterator&) = default;
326 transformed_iterator&
327 operator=(transformed_iterator&&) = default;
328
330 friend transformed_iterator&
331 operator+=(transformed_iterator& i, difference_type n)
332 ynoexcept(noexcept(decltype(i)(i)) && noexcept(i.get() += n))
333 {
334 i.get() += n;
335 return i;
336 }
337
339 friend transformed_iterator&
340 operator-=(transformed_iterator& i, difference_type n)
341 ynoexcept(noexcept(decltype(i)(i)) && noexcept(i.get() -= n))
342 {
343 i.get() -= n;
344 return i;
345 }
346
348 reference
349 operator*() const
350 ynoexcept_spec(reference(std::declval<transformed_iterator&>().
351 transformer(std::declval<transformed_iterator&>().get())))
352 {
353 return transformer(get());
354 }
355
357 transformed_iterator&
358 operator++()
359 {
360 ++get();
361 return *this;
362 }
363
365 transformed_iterator&
366 operator--()
367 {
368 --get();
369 return *this;
370 }
371
373
374 template<yimpl(typename = void)>
375 friend yconstfn bool
376 operator==(const transformed_iterator& x, const transformed_iterator& y)
377 ynoexcept_spec(bool(x.get() == y.get()))
378 {
379 return x.get() == y.get();
380 }
381 template<yimpl(typename = void)>
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 template<yimpl(typename = void)>
390 friend yconstfn bool
391 operator<(const transformed_iterator& x, const transformed_iterator& y)
392 ynoexcept_spec(bool(x.get() < y.get()))
393 {
394 return bool(x.get() < y.get());
395 }
396 template<yimpl(typename = void)>
397 friend yconstfn bool
398 operator<(const transformed_iterator& x, const iterator_type& y)
399 ynoexcept_spec(bool(x.get() < y))
400 {
401 return bool(x.get() < y);
402 }
403
404 template<yimpl(typename = void)>
405 friend yconstfn difference_type
406 operator-(const transformed_iterator& x, const transformed_iterator& y)
407 ynoexcept_spec(difference_type(x.get() - y.get()))
408 {
409 return difference_type(x.get() - y.get());
410 }
411 template<yimpl(typename = void)>
412 friend yconstfn difference_type
413 operator-(const transformed_iterator& x, const iterator_type& y)
414 ynoexcept_spec(difference_type(x.get() - y))
415 {
416 return difference_type(x.get() - y);
417 }
418 template<yimpl(typename = void)>
419 friend yconstfn difference_type
420 operator-(const iterator_type& x, const transformed_iterator& y)
421 ynoexcept_spec(difference_type(x - y.get()))
422 {
423 return difference_type(x - y.get());
424 }
426
428
429 yconstfn_relaxed iterator_type&
431 get() ynothrow
432 {
433 return transformed;
434 }
435
437 yconstfn const iterator_type&
438 get() const ynothrow
439 {
440 return transformed;
441 }
443
445
446 yconstfn_relaxed transformer_type&
447 get_transformer() ynothrow
448 {
449 return transformer;
450 }
451 yconstfn const transformer_type&
452 get_transformer() const ynothrow
453 {
454 return transformer;
455 }
457 };
458
465 template<typename _tIter, typename _fTrans>
466 inline transformed_iterator<decay_t<_tIter>, _fTrans>
467 make_transform(_tIter&& i, _fTrans f)
468 {
469 return transformed_iterator<decay_t<_tIter>, _fTrans>(yforward(i), f);
470 }
471
472
477 namespace iterator_transformation
478 {
479
481
482 template<typename _tIter = void>
483 struct first
484 {
486 yconstfn auto
487 operator()(const _tIter& i) const ynoexcept_spec(i->first)
488 -> decltype((i->first))
489 {
490 return i->first;
491 }
492 };
493
494 template<>
495 struct first<void>
496 {
498 template<typename _tIter>
499 yconstfn auto
500 operator()(const _tIter& i) const ynoexcept_spec(i->first)
501 -> decltype((i->first))
502 {
503 return i->first;
504 }
505 };
506
507
508 template<typename _tIter = void>
509 struct get
510 {
512 yconstfn auto
513 operator()(const _tIter& i) const ynoexcept_spec((*i).get())
514 -> decltype((*i).get())
515 {
516 return (*i).get();
517 }
518 };
519
520 template<>
521 struct get<void>
522 {
524 template<typename _tIter>
525 yconstfn auto
526 operator()(const _tIter& i) const ynoexcept_spec((*i).get())
527 -> decltype((*i).get())
528 {
529 return (*i).get();
530 }
531 };
532
533
534 template<typename _tIter = void>
535 struct indirect
536 {
538 yconstfn auto
539 operator()(const _tIter& i) const ynoexcept_spec(**i) -> decltype(**i)
540 {
541 return **i;
542 }
543 };
544
545 template<>
546 struct indirect<void>
547 {
549 template<typename _tIter>
550 yconstfn auto
551 operator()(const _tIter& i) const ynoexcept_spec(**i) -> decltype(**i)
552 {
553 return **i;
554 }
555 };
556
557
558 template<typename _tIter = void>
559 struct second
560 {
562 yconstfn auto
563 operator()(const _tIter& i) const ynoexcept_spec(i->second)
564 -> decltype((i->second))
565 {
566 return i->second;
567 }
568 };
569
570 template<>
571 struct second<void>
572 {
574 template<typename _tIter>
575 yconstfn auto
576 operator()(const _tIter& i) const ynoexcept_spec(i->second)
577 -> decltype((i->second))
578 {
579 return i->second;
580 }
581 };
583
584 } // namespace iterator_transformation;
585
586
592 yconstexpr const first_tag get_first{}, get_key{};
593 yconstexpr const second_tag get_second{}, get_value{};
595 yconstexpr const struct get_indirect_t{} get_indirect{};
597 yconstexpr const struct get_get_t{} get_get{};
599
600
607 template<typename _tIter>
608 inline auto
609 operator|(_tIter&& i, first_tag) -> decltype(make_transform(yforward(i),
610 iterator_transformation::first<>()))
611 {
612 return make_transform(yforward(i), iterator_transformation::first<>());
613 }
614 template<typename _tIter>
615 inline auto
616 operator|(_tIter&& i, second_tag) -> decltype(make_transform(yforward(i),
617 iterator_transformation::second<>()))
618 {
619 return make_transform(yforward(i), iterator_transformation::second<>());
620 }
622 template<typename _tIter>
623 inline auto
624 operator|(_tIter&& i, get_indirect_t) -> decltype(make_transform(yforward(i),
625 iterator_transformation::indirect<>()))
626 {
627 return make_transform(yforward(i), iterator_transformation::indirect<>());
628 }
630 template<typename _tIter>
631 inline auto
632 operator|(_tIter&& i, get_get_t)
633 -> decltype(make_transform(yforward(i), iterator_transformation::get<>()))
634 {
635 return make_transform(yforward(i), iterator_transformation::get<>());
636 }
638
639
649 template<typename _tIter, class _tTraits = std::iterator_traits<_tIter>,
650 typename... _tSlaves>
651 class tuple_iterator : private std::tuple<_tIter, _tSlaves...>, public
652 iterator_operators_t<tuple_iterator<_tIter, _tTraits, _tSlaves...>,
653 _tTraits>
654 {
655 public:
656 using base_type = std::tuple<_tIter, _tSlaves...>;
657 using iterator_type = _tIter;
658 using traits_type = _tTraits;
659 using iterator_category = typename traits_type::iterator_category;
660 using value_type = typename traits_type::value_type;
661 using difference_type = typename traits_type::difference_type;
662 using pointer = typename traits_type::pointer;
663 using reference = typename traits_type::reference;
664
665 private:
666 using seq_type = make_index_sequence<std::tuple_size<base_type>::value>;
667
668 public:
669 yconstfn
670 tuple_iterator() = default;
671 explicit yconstfn
672 tuple_iterator(const _tIter& i)
673 : base_type(i, _tSlaves()...)
674 {}
675 template<typename... _tParams>
676 yconstfn
677 tuple_iterator(const _tIter& i, _tParams&&... args)
678 : base_type(i, yforward(args)...)
679 {}
680 yconstfn
681 tuple_iterator(const tuple_iterator&) = default;
682 yconstfn
683 tuple_iterator(tuple_iterator&&) = default;
684
685 tuple_iterator&
686 operator=(const tuple_iterator&) = default;
687 tuple_iterator&
688 operator=(tuple_iterator&&) = default;
689
690 tuple_iterator&
691 operator+=(difference_type n) ynoexcept_spec(
692 yimpl(std::declval<tuple_iterator&>().add(n, seq_type())))
693 {
694 add(n, seq_type());
695 return *this;
696 }
697
698 tuple_iterator&
699 operator-=(difference_type n) ynoexcept_spec(
700 yimpl(std::declval<tuple_iterator&>().subtract(n, seq_type())))
701 {
702 subtract(n, seq_type());
703 return *this;
704 }
705
707
708 yconstfn reference
709 operator*() const
710 ynoexcept_spec(reference(*std::declval<tuple_iterator&>().get()))
711 {
712 return *get();
713 }
714
715 tuple_iterator&
716 operator++()
717 ynoexcept_spec(yimpl(std::declval<tuple_iterator&>().inc(seq_type())))
718 {
719 inc(seq_type());
720 return *this;
721 }
723
725 tuple_iterator&
726 operator--()
727 ynoexcept_spec(yimpl(std::declval<tuple_iterator&>().dec(seq_type())))
728 {
729 dec(seq_type());
730 return *this;
731 }
732
733 friend bool
734 operator==(const tuple_iterator& x, const tuple_iterator& y)
735 ynoexcept_spec(bool(x.get() == y.get()))
736 {
737 return x.get() == y.get();
738 }
739
740 private:
741 template<size_t... _vSeq>
742 void
743 add(difference_type n, index_sequence<_vSeq...>)
744 ynoexcept_spec(yimpl(yunseq((void(
745 std::get<_vSeq>(std::declval<tuple_iterator&>().base()) += n), 0)...)))
746 {
747 yunseq((void(std::get<_vSeq>(base()) += n), 0)...);
748 }
749
750 public:
751 yconstfn_relaxed base_type&
752 base() ynothrow
753 {
754 return *this;
755 }
756 yconstfn const base_type&
757 base() const ynothrow
758 {
759 return *this;
760 }
761
762 private:
763 template<size_t... _vSeq>
764 void
765 dec(index_sequence<_vSeq...>) ynoexcept_spec(yimpl(yunseq((void(
766 --std::get<_vSeq>(std::declval<tuple_iterator&>().base())), 0)...)))
767 {
768 yunseq((void(--std::get<_vSeq>(base())), 0)...);
769 }
770
771 template<size_t... _vSeq>
772 void
773 inc(index_sequence<_vSeq...>) ynoexcept_spec(yimpl(yunseq((void(
774 ++std::get<_vSeq>(std::declval<tuple_iterator&>().base())), 0)...)))
775 {
776 yunseq((void(++std::get<_vSeq>(base())), 0)...);
777 }
778
779 public:
780 yconstfn_relaxed iterator_type&
781 get() ynothrow
782 {
783 return std::get<0>(base());
784 }
785 yconstfn const iterator_type&
786 get() const ynothrow
787 {
788 return std::get<0>(base());
789 }
790
791 private:
792 template<size_t... _vSeq>
793 void
794 subtract(difference_type n, index_sequence<_vSeq...>)
795 ynoexcept_spec(yimpl(yunseq((void(
796 std::get<_vSeq>(std::declval<tuple_iterator&>().base()) -= n), 0)...)))
797 {
798 yunseq((void(std::get<_vSeq>(base()) -= n), 0)...);
799 }
800 };
801
802
810 template<typename _tIter, typename _tSlave,
811 class _tTraits = std::iterator_traits<_tIter>>
812 using pair_iterator = tuple_iterator<_tIter, _tTraits, _tSlave>;
813
814
821 template<typename _tIter>
822 class indirect_input_iterator : public iterator_operators_t<
823 indirect_input_iterator<_tIter>, std::iterator_traits<_tIter>>
824 {
825 public:
826 using iterator_type = _tIter;
827 using iterator_category = std::input_iterator_tag;
828 using value_type = typename std::iterator_traits<iterator_type>::value_type;
829 using difference_type
830 = typename std::iterator_traits<iterator_type>::difference_type;
831 using pointer = typename std::iterator_traits<iterator_type>::pointer;
832 using reference = typename std::iterator_traits<iterator_type>::reference;
833
834 private:
835 iterator_type iter;
836
837 public:
838 indirect_input_iterator()
839 : iter()
840 {}
841 indirect_input_iterator(iterator_type i)
842 : iter(i)
843 {
844 ++*this;
845 }
846 indirect_input_iterator(const indirect_input_iterator&) = default;
848 indirect_input_iterator(indirect_input_iterator&& i) ynothrow
849 : iter()
850 {
851 using std::swap;
852
853 swap(iter, i.iter);
854 }
855
856 indirect_input_iterator&
857 operator=(const indirect_input_iterator&) = default;
858 indirect_input_iterator&
859 #if YB_IMPL_MSCPP
860 operator=(indirect_input_iterator&& i)
862 {
863 iter = std::move(i.iter);
864 return *this;
865 }
866 #else
867 operator=(indirect_input_iterator&&) = default;
868 #endif
869
875 reference
876 operator*() const
877 {
878 yassume(!is_undereferenceable(iter));
879 return **iter;
880 }
881
886 indirect_input_iterator&
887 operator++()
888 {
889 yassume(!is_undereferenceable(iter));
890 ++*iter;
891 return *this;
892 }
893
894 friend bool
895 operator==(const indirect_input_iterator& x,
896 const indirect_input_iterator& y)
897 {
898 return (!bool(x) && !bool(y)) || x.iter == y.iter;
899 }
900
902 explicit
903 operator bool() const
904 {
905 return !is_undereferenceable(iter) && !is_undereferenceable(*iter);
906 }
907
908 iterator_type&
909 get() ynothrow
910 {
911 return iter;
912 }
913 const iterator_type&
914 get() const ynothrow
915 {
916 return iter;
917 }
918 };
919
920
931 template<typename _tIter>
932 class transposed_iterator : public iterator_operators_t<
933 transposed_iterator<_tIter>, std::iterator_traits<_tIter>>
934 {
935 public:
936 using iterator_type = _tIter;
937 using iterator_category = std::random_access_iterator_tag;
938 using value_type = typename std::iterator_traits<iterator_type>::value_type;
939 using difference_type
940 = typename std::iterator_traits<iterator_type>::difference_type;
941 using pointer = typename std::iterator_traits<iterator_type>::pointer;
942 using reference = typename std::iterator_traits<iterator_type>::reference;
943 using size_type = make_unsigned_t<difference_type>;
944
945 private:
946 iterator_type iter;
947 size_type width, height, row, col;
948
949 public:
950 transposed_iterator() = default;
952
953 yconstfn
954 transposed_iterator(iterator_type i, size_type w, size_type h)
955 ynoexcept(and_<is_nothrow_copy_constructible<iterator_type>,
956 is_nothrow_copy_constructible<size_type>>())
957 : iter(i), width((yconstraint(w != 0), w)),
958 height((yconstraint(h != 0), h)), row(), col(w)
959 {}
960 yconstfn
961 transposed_iterator(iterator_type i, size_type w, size_type h,
962 size_type idx)
963 ynoexcept(and_<is_nothrow_copy_constructible<iterator_type>,
964 is_nothrow_copy_constructible<size_type>>())
965 : iter(i), width((yconstraint(w != 0), w)),
966 height((yconstraint(h != 0), h)),
967 row((yconstraint(!(w * h < idx)), idx % h)), col(idx / h)
968 {}
970 transposed_iterator(const transposed_iterator&) = default;
971 #if YB_IMPL_MSCPP
972 transposed_iterator(transposed_iterator&& i)
974 : iter(std::move(i.iter)), width(std::move(i.width)),
975 height(std::move(i.height)), row(std::move(i.row)),
976 col(std::move(i.col))
977 {}
978 #else
979 transposed_iterator(transposed_iterator&&) = default;
980 #endif
981
982
983 transposed_iterator&
984 operator=(const transposed_iterator&) = default;
985 transposed_iterator&
986 operator=(transposed_iterator&&) = default;
987
988 transposed_iterator&
989 operator+=(difference_type n)
990 {
991 auto idx(col * height + row);
992
993 // NOTE: See $2015-02 @ %Documentation::Workflow::Annual2015.
994 yassume(!(difference_type(idx) < -n)),
995 yassume(!(difference_type(width * height) < difference_type(idx) + n));
996 idx += size_type(n);
997 yunseq(row = idx % height, col = idx / height);
998 return *this;
999 }
1000
1001 transposed_iterator&
1002 operator-=(difference_type n)
1003 {
1004 return *this += -n;
1005 }
1006
1007 reference
1008 operator*() const
1009 {
1010 yconstraint(!is_undereferenceable(*this));
1011 return *get();
1012 }
1013
1014 transposed_iterator&
1015 operator++()
1016 {
1017 yconstraint(!is_undereferenceable(*this));
1018 if(++row == height)
1019 yunseq(row = 0, ++col);
1020 return *this;
1021 }
1022
1023 transposed_iterator&
1024 operator--()
1025 {
1026 yconstraint(row != 0 || col != 0);
1027 if(row-- == 0)
1028 yunseq(row = height - 1, --col);
1029 return *this;
1030 }
1031
1033 friend bool
1034 operator==(const transposed_iterator& x, const transposed_iterator& y)
1035 {
1036 yconstraint(x.share_sequence(y));
1037
1038 return x.iter == y.iter && x.get_index() == y.get_index();
1039 }
1040
1041 friend bool
1042 operator<(const transposed_iterator& x, const transposed_iterator& y)
1043 {
1044 yconstraint(x.share_sequence(y));
1045 return x.row < y.row || (x.row == y.row && x.col < y.col);
1046 }
1047
1048 friend difference_type
1049 operator-(const transposed_iterator& x, const transposed_iterator& y)
1050 {
1051 yconstraint(x.share_sequence(y));
1052 // XXX: Conversion to 'difference_type' might be implementation-defined.
1053 return difference_type((x.col - y.col) * x.height + x.row - y.row);
1054 }
1055
1056 yconstfn const iterator_type&
1057 base() const ynothrow
1058 {
1059 return iter;
1060 }
1061
1062 iterator_type
1063 get() const ynothrowv
1064 {
1065 ynoexcept_assert("Invalid type found.", iter + row * width + col);
1066
1067 // XXX: Conversion to 'difference_type' might be implementation-defined.
1068 return iter + difference_type(get_index());
1069 }
1070
1071 friend bool
1072 is_undereferenceable(const transposed_iterator& i) ynothrow
1073 {
1074 using ystdex::is_undereferenceable;
1075
1076 return is_undereferenceable(i.iter)
1077 || !(i.row < i.height && i.col < i.width);
1078 }
1079
1080 yconstfn size_type
1081 get_column() const ynothrow
1082 {
1083 return col;
1084 }
1085
1086 yconstfn size_type
1087 get_height() const ynothrow
1088 {
1089 return height;
1090 }
1091
1092 yconstfn size_type
1093 get_index() const ynothrowv
1094 {
1095 ynoexcept_assert("Invalid type found.", row * width + col);
1096
1097 return row * width + col;
1098 }
1099
1100 yconstfn size_type
1101 get_row() const ynothrow
1102 {
1103 return row;
1104 }
1105
1106 yconstfn size_type
1107 get_width() const ynothrow
1108 {
1109 return width;
1110 }
1111
1112 bool
1113 share_sequence(const transposed_iterator& i) const ynothrow
1114 {
1115 yassume(!is_undereferenceable(*this)
1116 || (row == 0 && col == width)),
1117 yassume(!is_undereferenceable(i)
1118 || (i.row == 0 && i.col == i.width));
1119 return iter == i.iter && width == i.width && height == i.height;
1120 }
1121 };
1122
1129 template<typename _tIter, typename _tSize = make_unsigned_t<
1130 typename std::iterator_traits<decay_t<_tIter>>::difference_type>>
1131 inline transposed_iterator<decay_t<_tIter>>
1132 make_transposed(_tIter&& i, _tSize w, _tSize h)
1133 {
1134 return transposed_iterator<decay_t<_tIter>>(yforward(i), w, h);
1135 }
1136 template<typename _tIter, typename _tSize = make_unsigned_t<
1137 typename std::iterator_traits<decay_t<_tIter>>::difference_type>,
1138 typename _tIndex = _tSize>
1139 inline transposed_iterator<decay_t<_tIter>>
1140 make_transposed(_tIter&& i, _tSize w, _tSize h, _tIndex idx)
1141 {
1142 return transposed_iterator<decay_t<_tIter>>(yforward(i), w, h, idx);
1143 }
1145
1146
1152 template<typename _type, typename _fUpdater>
1153 class prototyped_iterator : public iterator_operators_t<
1154 prototyped_iterator<_type, _fUpdater>, std::iterator_traits<yimpl(_type*)>>
1155 {
1156 public:
1157 using updater_type = _fUpdater;
1158 using iterator_category = std::random_access_iterator_tag;
1159 using value_type = _type;
1160 using difference_type = ptrdiff_t;
1161 using pointer = _type*;
1162 using reference = _type&;
1163
1164 protected:
1166 lref<value_type> proto_ref;
1167 size_t idx;
1168 updater_type updater;
1169
1170 public:
1171 template<typename _fCallable>
1172 yconstfn
1173 prototyped_iterator(value_type& proto, size_t i, _fCallable&& f)
1174 : proto_ref(proto), idx(i), updater(yforward(f))
1175 {}
1176
1177 prototyped_iterator&
1178 operator+=(difference_type n)
1179 {
1180 idx += n;
1181 return *this;
1182 }
1183
1184 prototyped_iterator&
1185 operator-=(difference_type n)
1186 {
1187 yassume(!(idx < n));
1188 idx -= n;
1189 return *this;
1190 }
1191
1192 reference
1193 operator*() const
1194 {
1195 updater(proto_ref.get(), idx);
1196 return proto_ref;
1197 }
1198
1199 prototyped_iterator&
1200 operator++() ynothrow
1201 {
1202 ++idx;
1203 return *this;
1204 }
1205
1206 prototyped_iterator
1207 operator--() ynothrow
1208 {
1209 --idx;
1210 return *this;
1211 }
1212
1214 friend bool
1215 operator==(const prototyped_iterator& x, const prototyped_iterator& y)
1216 ynothrow
1217 {
1218 return std::addressof(x.proto_ref.get())
1219 == std::addressof(y.proto_ref.get()) && x.idx == y.idx;
1220 }
1221 };
1222
1229 template<typename _type, typename _fUpdater>
1230 yconstfn prototyped_iterator<_type, _fUpdater>
1231 make_prototyped_iterator(_type& proto, size_t i, _fUpdater f)
1232 {
1233 return prototyped_iterator<_type, _fUpdater>(proto, i, f);
1234 }
1235
1236
1245 template<class _tCon, typename _type, typename _tDifference = ptrdiff_t,
1246 typename _tPointer = _type*, typename _tReference = _type&>
1247 class subscriptive_iterator : public random_access_iteratable<
1248 subscriptive_iterator<_tCon, _type, _tDifference, _tPointer, _tReference>,
1249 _tDifference, _tReference>
1250 {
1251 public:
1253
1254 using container_type = _tCon;
1255 using iterator_category = std::random_access_iterator_tag;
1256 using value_type = _type;
1257 using difference_type = _tDifference;
1258 using pointer = _tPointer;
1259 using reference = _tReference;
1261
1262 protected:
1263 _tCon* container_ptr = {};
1264 size_t index = size_t(-1);
1265
1266 public:
1271 subscriptive_iterator() = default;
1273 yconstfn
1274 subscriptive_iterator(container_type& c, size_t i) ynothrowv
1275 : container_ptr(std::addressof(c)), index(i)
1276 {}
1277
1279
1280 subscriptive_iterator&
1281 operator+=(difference_type n) ynothrowv
1282 {
1283 index += n;
1284 return *this;
1285 }
1286
1287 subscriptive_iterator&
1288 operator-=(difference_type n) ynothrowv
1289 {
1290 yassume(!(index < n));
1291 index -= n;
1292 return *this;
1293 }
1295
1297
1298 reference
1299 operator*() const ynothrowv
1300 {
1301 yassume(!is_undereferenceable(*this));
1302 return (*container_ptr)[index];
1303 }
1304
1305 subscriptive_iterator&
1306 operator++() ynothrow
1307 {
1308 ++index;
1309 return *this;
1310 }
1311
1312 subscriptive_iterator
1313 operator--() ynothrow
1314 {
1315 --index;
1316 return *this;
1317 }
1319
1321 friend bool
1322 operator==(const subscriptive_iterator& x, const subscriptive_iterator& y)
1323 ynothrow
1324 {
1325 yconstraint(x.container() == y.container());
1326 return is_undereferenceable(y) || x.index == y.index;
1327 }
1328
1330 friend bool
1331 operator<(const subscriptive_iterator& x, const subscriptive_iterator& y)
1332 ynothrow
1333 {
1334 yconstraint(x.container() == y.container());
1335 return x.index < y.index;
1336 }
1337
1339 friend _tDifference
1340 operator-(const subscriptive_iterator& x, const subscriptive_iterator& y)
1341 ynothrow
1342 {
1343 yconstraint(x.container_ptr == y.container_ptr);
1344 return _tDifference(x.index - y.index);
1345 }
1346
1348 yconstfn _tCon*
1349 container() const ynothrow
1350 {
1351 return container_ptr;
1352 }
1353
1354 yconstfn size_t
1355 get_index() const ynothrow
1356 {
1357 return index;
1358 }
1359
1361 friend bool
1362 is_undereferenceable(const subscriptive_iterator& i) ynothrow
1363 {
1364 return !i.container_ptr;
1365 }
1366 };
1367
1368 } // namespace ystdex;
1369
1370 #endif
1371
YSLib::ValueNode::container
Container container
子节点容器。
Definition: ValueNode.h:80
ystdex::pseudo_iterator::operator-=
pseudo_iterator & operator-=(difference_type)
Definition: iterator.hpp:118
ystdex::transformed_iterator::transformed_type
typename impl_traits::transformed_type transformed_type
Definition: iterator.hpp:248
ystdex::tuple_iterator::base_type
std::tuple< _tIter, _tSlaves... > base_type
Definition: iterator.hpp:656
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:1362
ystdex::subscriptive_iterator
成员下标迭代器。
Definition: iterator.hpp:1247
ystdex::details::transit_traits::iterator_type
_t< pointer_classify< _tIter >> iterator_type
Definition: iterator.hpp:186
ystdex::transposed_iterator::height
size_type height
Definition: iterator.hpp:947
ystdex::subscriptive_iterator::container
_tCon * container() const
Definition: iterator.hpp:1349
ystdex::transformed_iterator::iterator_category
typename impl_traits::iterator_category iterator_category
Definition: iterator.hpp:244
ystdex::cpp2014::make_unsigned_t
typename make_unsigned< _type >::type make_unsigned_t
Definition: type_traits.hpp:312
ystdex::tuple_iterator::operator==
friend bool operator==(const tuple_iterator &x, const tuple_iterator &y)
Definition: iterator.hpp:734
ystdex::get_indirect
const struct ystdex::get_indirect_t get_indirect
ystdex::cond_t
conditional_t< _tCond::value, _tThen, _tElse > cond_t
条件判断。
Definition: type_traits.hpp:738
ystdex::transformed_iterator::operator=
transformed_iterator & operator=(const transformed_iterator &)=default
ystdex::subscriptive_iterator::operator+=
subscriptive_iterator & operator+=(difference_type n)
Definition: iterator.hpp:1281
ystdex::tuple_iterator::value_type
typename traits_type::value_type value_type
Definition: iterator.hpp:660
yconstfn
#define yconstfn
指定编译时常量函数。
Definition: ydef.h:680
ystdex::transposed_iterator::row
size_type row
Definition: iterator.hpp:947
ystdex::transposed_iterator::col
size_type col
Definition: iterator.hpp:947
ystdex::transposed_iterator::operator<
friend bool operator<(const transposed_iterator &x, const transposed_iterator &y)
Definition: iterator.hpp:1042
v
byte v
Definition: CharRenderer.cpp:75
ystdex::prototyped_iterator::operator--
prototyped_iterator operator--()
Definition: iterator.hpp:1207
ystdex::pseudo_iterator::iterator_type
_tIter iterator_type
Definition: iterator.hpp:66
ystdex::transformed_iterator::operator+=
friend transformed_iterator & operator+=(transformed_iterator &i, difference_type n)
Definition: iterator.hpp:331
ystdex::transformed_iterator::operator-
friend difference_type operator-(const transformed_iterator &x, const iterator_type &y)
Definition: iterator.hpp:413
ystdex::transformed_iterator::difference_type
typename impl_traits::difference_type difference_type
Definition: iterator.hpp:250
ystdex::iterator_operators_t
_t< details::iterator_operators< _tIter, _tTraits >> iterator_operators_t
按迭代器类别取可实现迭代器的重载操作符集合的实现。
Definition: iterator_op.hpp:191
ystdex::iterator_transformation::indirect::operator()
auto operator()(const _tIter &i) const -> decltype(**i)
Definition: iterator.hpp:539
ystdex::dep_ops::totally_ordered
details::flat_ops< _type, _type2, _tOpt, less_than_comparable, equality_comparable > totally_ordered
Definition: operators.hpp:367
ystdex::transformed_iterator::operator==
friend bool operator==(const transformed_iterator &x, const iterator_type &y)
Definition: iterator.hpp:383
ystdex::indirect_input_iterator::operator*
reference operator*() const
间接操作。
Definition: iterator.hpp:876
ystdex::iterator_transformation::indirect< void >::operator()
auto operator()(const _tIter &i) const -> decltype(**i)
Definition: iterator.hpp:551
ystdex::subscriptive_iterator::pointer
_tPointer pointer
Definition: iterator.hpp:1258
ystdex::details::ebases
Definition: operators.hpp:100
ystdex::tuple_iterator::operator++
tuple_iterator & operator++()
Definition: iterator.hpp:716
ystdex::transformed_iterator::transformed
iterator_type transformed
Definition: iterator.hpp:265
YSLib::UI::y
SPos SPos y
Definition: YWidget.cpp:44
NPL::x
const TermNode &term ynothrow const TermNode &term ynothrow const TermNode &term ynothrow TermNode &term const TermNode &term ValueNode &node const ValueNode &node const _type & x
Definition: SContext.h:94
ystdex::subscriptive_iterator::get_index
size_t get_index() const
Definition: iterator.hpp:1355
platform::size_t
YF_API size_t
Definition: FileIO.h:1353
ystdex::get_get_t
Definition: iterator.hpp:597
ystdex::subscriptive_iterator::operator-=
subscriptive_iterator & operator-=(difference_type n)
Definition: iterator.hpp:1288
ystdex::pseudo_iterator::operator*
reference operator*()
满足前向迭代器要求。
Definition: iterator.hpp:127
ystdex::indirect_input_iterator::indirect_input_iterator
indirect_input_iterator(iterator_type i)
Definition: iterator.hpp:841
ystdex::transformed_iterator::transformed_iterator
transformed_iterator(_tIter2 &&i)
Definition: iterator.hpp:278
ystdex::transformed_iterator::operator-
friend difference_type operator-(const transformed_iterator &x, const transformed_iterator &y)
Definition: iterator.hpp:406
ystdex::get_key
const first_tag get_key
Definition: iterator.hpp:592
ystdex::indirect_input_iterator::operator=
indirect_input_iterator & operator=(const indirect_input_iterator &)=default
ystdex::transformed_iterator::value_type
typename impl_traits::transformed_type value_type
Definition: iterator.hpp:245
CHRLib::f
f(d, s)
ystdex::not_
Definition: type_traits.hpp:456
ynoexcept_assert
#define ynoexcept_assert(_msg,...)
表达式 noexcept 静态断言。
Definition: ydef.h:747
ystdex::prototyped_iterator::difference_type
ptrdiff_t difference_type
Definition: iterator.hpp:1160
ynoexcept_spec
#define ynoexcept_spec(...)
表达式 noexcept 异常规范。
Definition: ydef.h:794
ystdex::subscriptive_iterator::operator==
friend bool operator==(const subscriptive_iterator &x, const subscriptive_iterator &y)
Definition: iterator.hpp:1322
ystdex::tuple_iterator::operator--
tuple_iterator & operator--()
满足双向迭代器要求。
Definition: iterator.hpp:726
platform::bool
std::FILE *fp bool
Definition: FileIO.h:1280
yimpl
#define yimpl(...)
实现标签。
Definition: ydef.h:262
ystdex::prototyped_iterator::operator++
prototyped_iterator & operator++()
Definition: iterator.hpp:1200
ystdex::prototyped_iterator::proto_ref
lref< value_type > proto_ref
Definition: iterator.hpp:1166
ystdex::indirect_input_iterator::difference_type
typename std::iterator_traits< iterator_type >::difference_type difference_type
Definition: iterator.hpp:830
ystdex::pseudo_iterator::pointer
typename traits_type::pointer pointer
Definition: iterator.hpp:72
yconstfn_relaxed
#define yconstfn_relaxed
指定编译时没有 C++11 限制和隐式成员 const 的常量函数。
Definition: ydef.h:692
ystdex::subscriptive_iterator::operator<
friend bool operator<(const subscriptive_iterator &x, const subscriptive_iterator &y)
Definition: iterator.hpp:1331
ystdex::transposed_iterator::operator-=
transposed_iterator & operator-=(difference_type n)
Definition: iterator.hpp:1002
ystdex::cpp2014::enable_if_t
typename enable_if< _bCond, _type >::type enable_if_t
Definition: type_traits.hpp:343
ystdex::subscriptive_iterator::operator++
subscriptive_iterator & operator++()
Definition: iterator.hpp:1306
ystdex::tuple_iterator::dec
void dec(index_sequence< _vSeq... >)
Definition: iterator.hpp:765
ystdex::transposed_iterator::operator*
reference operator*() const
Definition: iterator.hpp:1008
CHRLib::args
_tParams && args
Definition: CharacterProcessing.h:538
yconstexpr
#define yconstexpr
指定编译时常量表达式。
Definition: ydef.h:679
ystdex::is_undereferenceable
bool is_undereferenceable(const _tIter &)
Definition: deref_op.hpp:45
ystdex::transposed_iterator::reference
typename std::iterator_traits< iterator_type >::reference reference
Definition: iterator.hpp:942
ystdex::pseudo_iterator::pseudo_iterator
pseudo_iterator()=default
ystdex::tuple_iterator::tuple_iterator
tuple_iterator(const _tIter &i)
Definition: iterator.hpp:672
ystdex::pseudo_iterator
伪迭代器。
Definition: iterator.hpp:62
ystdex::operator|
auto operator|(_tIter &&i, first_tag) -> decltype(make_transform(std::forward< decltype(i)>(i), iterator_transformation::first<>()))
管道匹配操作符。
Definition: iterator.hpp:609
ystdex::pseudo_iterator::operator+=
pseudo_iterator & operator+=(difference_type)
Definition: iterator.hpp:112
ystdex::tuple_iterator
元组迭代器。
Definition: iterator.hpp:651
ystdex::transformed_iterator::transformed_iterator
transformed_iterator(const transformed_iterator< _tIter2, _fTrans2, _tRef2 > &i)
Definition: iterator.hpp:295
yunseq
#define yunseq
无序列依赖表达式组求值。
Definition: ydef.h:1022
ystdex::tuple_iterator::add
void add(difference_type n, index_sequence< _vSeq... >)
Definition: iterator.hpp:743
ystdex::details::transit_traits::pointer
remove_reference_t< reference > * pointer
Definition: iterator.hpp:198
ystdex::transposed_iterator
下标转置迭代器适配器。
Definition: iterator.hpp:932
ystdex::lref< value_type >
ystdex::prototyped_iterator::prototyped_iterator
prototyped_iterator(value_type &proto, size_t i, _fCallable &&f)
Definition: iterator.hpp:1173
ystdex::pseudo_iterator::operator++
pseudo_iterator & operator++()
Definition: iterator.hpp:138
ystdex::tuple_iterator::get
iterator_type & get()
Definition: iterator.hpp:781
ystdex::subscriptive_iterator::operator*
reference operator*() const
Definition: iterator.hpp:1299
ystdex::transformed_iterator::iterator_type
typename impl_traits::iterator_type iterator_type
原迭代器类型。
Definition: iterator.hpp:240
ystdex::prototyped_iterator::updater
updater_type updater
Definition: iterator.hpp:1168
ystdex::iterator_transformation::first::operator()
auto operator()(const _tIter &i) const -> decltype((i->first))
Definition: iterator.hpp:487
ystdex::pseudo_iterator::operator*
reference operator*() const
Definition: iterator.hpp:132
ystdex::tuple_iterator::seq_type
make_index_sequence< std::tuple_size< base_type >::value > seq_type
Definition: iterator.hpp:666
ystdex::transposed_iterator::get_column
size_type get_column() const
Definition: iterator.hpp:1081
ystdex::indirect_input_iterator::operator==
friend bool operator==(const indirect_input_iterator &x, const indirect_input_iterator &y)
Definition: iterator.hpp:895
ystdex::tuple_iterator::operator*
reference operator*() const
满足输入迭代器要求。
Definition: iterator.hpp:709
ystdex::transposed_iterator::get_index
size_type get_index() const
Definition: iterator.hpp:1093
ystdex::prototyped_iterator::iterator_category
std::random_access_iterator_tag iterator_category
Definition: iterator.hpp:1158
ystdex::subscriptive_iterator::reference
_tReference reference
Definition: iterator.hpp:1259
YSLib::Drawing::w
The boundary is out of the const Rect SDst w
Definition: YDraw.h:127
ystdex::indirect_input_iterator::reference
typename std::iterator_traits< iterator_type >::reference reference
Definition: iterator.hpp:832
ystdex::prototyped_iterator::operator+=
prototyped_iterator & operator+=(difference_type n)
Definition: iterator.hpp:1178
ystdex::transposed_iterator::iterator_type
_tIter iterator_type
Definition: iterator.hpp:936
ynothrow
#define ynothrow
YSLib 无异常抛出保证：若支持 noexcept 关键字， 指定特定的 noexcept 异常规范。
Definition: ydef.h:766
ystdex::transposed_iterator::value_type
typename std::iterator_traits< iterator_type >::value_type value_type
Definition: iterator.hpp:938
ystdex::transformed_iterator
变换迭代器。
Definition: iterator.hpp:216
ystdex::transformed_iterator::transformed_iterator
transformed_iterator(transformed_iterator< _tIter2, _fTrans2, _tRef2 > &&i)
Definition: iterator.hpp:306
ystdex::transformed_iterator::make_transform
transformed_iterator< decay_t< _tIter >, _fTrans > make_transform(_tIter &&i, _fTrans f)
创建变换迭代器。
Definition: iterator.hpp:467
ystdex::pseudo_iterator::operator-
friend difference_type operator-(const pseudo_iterator &, const pseudo_iterator &)
Definition: iterator.hpp:171
ystdex
特性测试宏。
Definition: ydef.h:822
ystdex::iterator_transformation::first
Definition: iterator.hpp:483
ystdex::indirect_input_iterator::indirect_input_iterator
indirect_input_iterator(indirect_input_iterator &&i)
Definition: iterator.hpp:848
ystdex::iterator_transformation::get
Definition: iterator.hpp:509
ystdex::lref::get
_type & get() const
Definition: ref.hpp:108
ystdex::tuple_iterator::inc
void inc(index_sequence< _vSeq... >)
Definition: iterator.hpp:773
YSLib::i
return i
Definition: YCoreUtilities.h:176
ystdex::pseudo_iterator::traits_type
_tTraits traits_type
Definition: iterator.hpp:68
ystdex::transposed_iterator::operator=
transposed_iterator & operator=(const transposed_iterator &)=default
ystdex::iterator_transformation::second< void >::operator()
auto operator()(const _tIter &i) const -> decltype((i->second))
Definition: iterator.hpp:576
ystdex::transformed_iterator::transformer
transformer_type transformer
Definition: iterator.hpp:261
ystdex::subscriptive_iterator::subscriptive_iterator
subscriptive_iterator(container_type &c, size_t i)
Definition: iterator.hpp:1274
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::transformed_iterator::pointer
typename impl_traits::pointer pointer
Definition: iterator.hpp:252
ystdex::tuple_iterator::difference_type
typename traits_type::difference_type difference_type
Definition: iterator.hpp:661
ystdex::get_get
const struct ystdex::get_get_t get_get
ystdex::pseudo_iterator::pseudo_iterator
pseudo_iterator(value_type v)
Definition: iterator.hpp:80
ref.hpp
引用包装。
ystdex::transposed_iterator::iter
iterator_type iter
Definition: iterator.hpp:946
ystdex::indirect_input_iterator::indirect_input_iterator
indirect_input_iterator()
Definition: iterator.hpp:838
type_op.hpp
C++ 类型操作。
ystdex::pseudo_iterator::operator=
pseudo_iterator & operator=(const pseudo_iterator &)=default
ystdex::pseudo_iterator::operator--
pseudo_iterator & operator--()
满足双向迭代器要求。
Definition: iterator.hpp:148
ystdex::tuple_iterator::reference
typename traits_type::reference reference
Definition: iterator.hpp:663
ystdex::transposed_iterator::get_row
size_type get_row() const
Definition: iterator.hpp:1101
ystdex::transposed_iterator::iterator_category
std::random_access_iterator_tag iterator_category
Definition: iterator.hpp:937
ystdex::prototyped_iterator::idx
size_t idx
Definition: iterator.hpp:1167
ystdex::transposed_iterator::size_type
make_unsigned_t< difference_type > size_type
Definition: iterator.hpp:943
ystdex::tuple_iterator::tuple_iterator
tuple_iterator()=default
ystdex::subscriptive_iterator::operator-
friend _tDifference operator-(const subscriptive_iterator &x, const subscriptive_iterator &y)
Definition: iterator.hpp:1340
ystdex::_t
typename _type::type _t
嵌套类型别名。
Definition: type_traits.hpp:97
ystdex::iterator_transformation::first< void >::operator()
auto operator()(const _tIter &i) const -> decltype((i->first))
Definition: iterator.hpp:500
ystdex::transposed_iterator::make_transposed
transposed_iterator< decay_t< _tIter > > make_transposed(_tIter &&i, _tSize w, _tSize h)
Definition: iterator.hpp:1132
ystdex::transposed_iterator::operator++
transposed_iterator & operator++()
Definition: iterator.hpp:1015
ystdex::indirect_input_iterator::iterator_category
std::input_iterator_tag iterator_category
Definition: iterator.hpp:827
pointer.hpp
通用指针。
ystdex::iterator_transformation::indirect
Definition: iterator.hpp:535
ystdex::prototyped_iterator::operator-=
prototyped_iterator & operator-=(difference_type n)
Definition: iterator.hpp:1185
ystdex::iterator_transformation::get::operator()
auto operator()(const _tIter &i) const -> decltype((*i).get())
Definition: iterator.hpp:513
ystdex::transposed_iterator::operator+=
transposed_iterator & operator+=(difference_type n)
Definition: iterator.hpp:989
ystdex::transposed_iterator::transposed_iterator
transposed_iterator(iterator_type i, size_type w, size_type h, size_type idx)
Definition: iterator.hpp:961
ystdex::is_decayed
判断指定类型是否已退化。
Definition: type_traits.hpp:906
ystdex::prototyped_iterator::updater_type
_fUpdater updater_type
Definition: iterator.hpp:1157
ystdex::transformed_iterator::get_transformer
const transformer_type & get_transformer() const
Definition: iterator.hpp:452
ystdex::n_tag
自然数标记。
Definition: type_op.hpp:355
ynothrowv
#define ynothrowv
YSLib 无异常抛出保证验证：有条件地使用无异常抛出规范。
Definition: ydef.h:786
ystdex::pseudo_iterator::difference_type
typename traits_type::difference_type difference_type
Definition: iterator.hpp:71
ystdex::indirect_input_iterator::operator++
indirect_input_iterator & operator++()
迭代：向后遍历。
Definition: iterator.hpp:887
ystdex::pseudo_iterator::value
value_type value
Definition: iterator.hpp:75
ystdex::transformed_iterator::operator<
friend bool operator<(const transformed_iterator &x, const transformed_iterator &y)
Definition: iterator.hpp:391
ystdex::tuple_iterator::traits_type
_tTraits traits_type
Definition: iterator.hpp:658
ystdex::tuple_iterator::base
base_type & base()
Definition: iterator.hpp:752
ystdex::get_value
const second_tag get_value
Definition: iterator.hpp:593
ystdex::swap
void swap(container_adaptor< _tSeqCon > &x, container_adaptor< _tSeqCon > &y)
Definition: container.hpp:179
ystdex::get_first
const first_tag get_first
操纵子。
Definition: iterator.hpp:592
ystdex::exclude_self_t
enable_if_t<!is_same< _tClass &, decay_t< _tParam > & >::value, _type > exclude_self_t
移除选择类类型的特定重载避免构造模板和复制/转移特殊成员函数冲突。
Definition: type_traits.hpp:748
ystdex::transformed_iterator::transformed_iterator
transformed_iterator()=default
ystdex::indirect_input_iterator::value_type
typename std::iterator_traits< iterator_type >::value_type value_type
Definition: iterator.hpp:828
ystdex::tuple_iterator::subtract
void subtract(difference_type n, index_sequence< _vSeq... >)
Definition: iterator.hpp:794
ystdex::transformed_iterator::get_transformer
transformer_type & get_transformer()
Definition: iterator.hpp:447
ystdex::transposed_iterator::get_height
size_type get_height() const
Definition: iterator.hpp:1087
std
Definition: memory.hpp:1183
ystdex::prototyped_iterator::operator==
friend bool operator==(const prototyped_iterator &x, const prototyped_iterator &y)
Definition: iterator.hpp:1215
ystdex::tuple_iterator::pointer
typename traits_type::pointer pointer
Definition: iterator.hpp:662
ystdex::get_second
const second_tag get_second
Definition: iterator.hpp:593
ystdex::subscriptive_iterator::operator--
subscriptive_iterator operator--()
Definition: iterator.hpp:1313
ystdex::transposed_iterator::transposed_iterator
transposed_iterator(iterator_type i, size_type w, size_type h)
Definition: iterator.hpp:954
ystdex::prototyped_iterator::value_type
_type value_type
Definition: iterator.hpp:1159
ystdex::pseudo_iterator::operator==
friend bool operator==(const pseudo_iterator &x, const pseudo_iterator &y)
Definition: iterator.hpp:157
ystdex::subscriptive_iterator::container_ptr
_tCon * container_ptr
Definition: iterator.hpp:1263
ystdex::transformed_iterator::operator==
friend bool operator==(const transformed_iterator &x, const transformed_iterator &y)
Definition: iterator.hpp:376
ystdex::iterator_transformation::second::operator()
auto operator()(const _tIter &i) const -> decltype((i->second))
Definition: iterator.hpp:563
ystdex::tuple_iterator::operator+=
tuple_iterator & operator+=(difference_type n)
Definition: iterator.hpp:691
ystdex::transposed_iterator::difference_type
typename std::iterator_traits< iterator_type >::difference_type difference_type
Definition: iterator.hpp:940
ystdex::transposed_iterator::is_undereferenceable
friend bool is_undereferenceable(const transposed_iterator &i)
Definition: iterator.hpp:1072
ystdex::pseudo_iterator::operator<
friend bool operator<(const pseudo_iterator &x, const pseudo_iterator &y)
Definition: iterator.hpp:164
ystdex::subscriptive_iterator::container_type
_tCon container_type
Definition: iterator.hpp:1254
ystdex::n_tag< 0 >
Definition: type_op.hpp:361
ystdex::indirect_input_iterator::iterator_type
_tIter iterator_type
Definition: iterator.hpp:826
ystdex::transformed_iterator::operator*
reference operator*() const
Definition: iterator.hpp:349
ystdex::transposed_iterator::transposed_iterator
transposed_iterator()=default
CHRLib::c
c
Definition: CharacterProcessing.h:81
ystdex::subscriptive_iterator::subscriptive_iterator
subscriptive_iterator()=default
ystdex::prototyped_iterator
原型迭代器：共享对象引用，在解引用时进行指定的更新操作的随机访问迭代器。
Definition: iterator.hpp:1153
ystdex::transposed_iterator::operator==
friend bool operator==(const transposed_iterator &x, const transposed_iterator &y)
Definition: iterator.hpp:1034
ystdex::transformed_iterator::operator--
transformed_iterator & operator--()
Definition: iterator.hpp:366
ystdex::indirect_input_iterator
间接输入迭代器。
Definition: iterator.hpp:822
yforward
#define yforward(_expr)
根据参数类型使用 std::forward 传递对应参数。
Definition: ydef.h:995
yassume
#define yassume(_expr)
假定：环境语义。
Definition: cassert.h:105
ystdex::prototyped_iterator::pointer
_type * pointer
Definition: iterator.hpp:1161
ystdex::enable_if_convertible_t
enable_if_t< is_convertible< _tFrom, _tTo >::value, _type > enable_if_convertible_t
Definition: type_traits.hpp:1052
ystdex::prototyped_iterator::reference
_type & reference
Definition: iterator.hpp:1162
ystdex::indirect_input_iterator::iter
iterator_type iter
Definition: iterator.hpp:835
ystdex::subscriptive_iterator::index
size_t index
Definition: iterator.hpp:1264
ystdex::pseudo_iterator::value_type
typename traits_type::value_type value_type
Definition: iterator.hpp:70
ystdex::tuple_iterator::operator-=
tuple_iterator & operator-=(difference_type n)
Definition: iterator.hpp:699
ystdex::details::transit_traits
Definition: iterator.hpp:184
ystdex::tuple_iterator::base
const base_type & base() const
Definition: iterator.hpp:757
ystdex::transposed_iterator::operator--
transposed_iterator & operator--()
Definition: iterator.hpp:1024
ystdex::transformed_iterator::transformer_type
_fTrans transformer_type
Definition: iterator.hpp:241
ystdex::prototyped_iterator::make_prototyped_iterator
prototyped_iterator< _type, _fUpdater > make_prototyped_iterator(_type &proto, size_t i, _fUpdater f)
创建原型迭代器。
Definition: iterator.hpp:1231
ystdex::details::transit_traits::iterator_category
typename std::iterator_traits< iterator_type >::iterator_category iterator_category
Definition: iterator.hpp:188
ystdex::pseudo_iterator::iterator_category
typename traits_type::iterator_category iterator_category
Definition: iterator.hpp:69
ystdex::tuple_iterator::iterator_type
_tIter iterator_type
Definition: iterator.hpp:657
ystdex::iterator_transformation::second
Definition: iterator.hpp:559
ystdex::transposed_iterator::share_sequence
bool share_sequence(const transposed_iterator &i) const
Definition: iterator.hpp:1113
ystdex::tuple_iterator::iterator_category
typename traits_type::iterator_category iterator_category
Definition: iterator.hpp:659
ystdex::transformed_iterator::operator-=
friend transformed_iterator & operator-=(transformed_iterator &i, difference_type n)
Definition: iterator.hpp:340
ystdex::details::transit_traits::reference
cond_t< is_same< _tReference, void >, transformed_type, _tReference > reference
Definition: iterator.hpp:193
ystdex::transformed_iterator::get
iterator_type & get()
取原迭代器引用。
Definition: iterator.hpp:431
ystdex::details::transit_traits::transformed_type
result_of_t< _fTrans &(_tIter &)> transformed_type
Definition: iterator.hpp:189
ystdex::details::transit_traits::difference_type
typename std::iterator_traits< iterator_type >::difference_type difference_type
Definition: iterator.hpp:191
yconstraint
#define yconstraint(_expr)
约束：接口语义。
Definition: cassert.h:88
ystdex::transposed_iterator::pointer
typename std::iterator_traits< iterator_type >::pointer pointer
Definition: iterator.hpp:941
ystdex::and_
逻辑操作元函数。
Definition: type_traits.hpp:420
ystdex::transformed_iterator::reference
typename impl_traits::reference reference
Definition: iterator.hpp:257
ystdex::subscriptive_iterator::value_type
_type value_type
Definition: iterator.hpp:1256
ystdex::iterator_transformation::get< void >::operator()
auto operator()(const _tIter &i) const -> decltype((*i).get())
Definition: iterator.hpp:526
ystdex::prototyped_iterator::operator*
reference operator*() const
Definition: iterator.hpp:1193
ystdex::subscriptive_iterator::difference_type
_tDifference difference_type
Definition: iterator.hpp:1257
ystdex::transposed_iterator::width
size_type width
Definition: iterator.hpp:947
ystdex::transformed_iterator::operator-
friend difference_type operator-(const iterator_type &x, const transformed_iterator &y)
Definition: iterator.hpp:420
ystdex::transformed_iterator::operator++
transformed_iterator & operator++()
Definition: iterator.hpp:358
ystdex::transposed_iterator::base
const iterator_type & base() const
Definition: iterator.hpp:1057
ystdex::transposed_iterator::operator-
friend difference_type operator-(const transposed_iterator &x, const transposed_iterator &y)
Definition: iterator.hpp:1049
ystdex::tuple_iterator::tuple_iterator
tuple_iterator(const _tIter &i, _tParams &&...args)
Definition: iterator.hpp:677
ystdex::get_indirect_t
Definition: iterator.hpp:595
ystdex::subscriptive_iterator::iterator_category
std::random_access_iterator_tag iterator_category
Definition: iterator.hpp:1255
ynoexcept
#define ynoexcept(...)
YSLib 无异常抛出保证：指定特定的异常规范。
Definition: ydef.h:746
ystdex::transposed_iterator::get_width
size_type get_width() const
Definition: iterator.hpp:1107
ystdex::indirect_input_iterator::pointer
typename std::iterator_traits< iterator_type >::pointer pointer
Definition: iterator.hpp:831