Dune Core Modules (unstable)

iteratorfacades.hh
Go to the documentation of this file.
1// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
2// vi: set et ts=4 sw=2 sts=2:
3// SPDX-FileCopyrightInfo: Copyright © DUNE Project contributors, see file LICENSE.md in module root
4// SPDX-License-Identifier: LicenseRef-GPL-2.0-only-with-DUNE-exception
5#ifndef DUNE_ITERATORFACADES_HH
6#define DUNE_ITERATORFACADES_HH
7
8#include <iterator>
9#include <type_traits>
10
13
14namespace Dune
15{
140 template<class T, class V, class R = V&, class D = std::ptrdiff_t>
142 {
143
144 public:
145 /* type aliases required by C++ for iterators */
146 using iterator_category = std::forward_iterator_tag;
147 using value_type = typename std::remove_const<V>::type;
148 using difference_type = D;
149 using pointer = V*;
150 using reference = R;
151
176 typedef T DerivedType;
177
181 typedef V Value;
182
186 typedef V* Pointer;
187
191 typedef D DifferenceType;
192
196 typedef R Reference;
197
200 {
201 return static_cast<DerivedType const*>(this)->dereference();
202 }
203
204 Pointer operator->() const
205 {
206 return &(static_cast<const DerivedType *>(this)->dereference());
207 }
208
211 {
212 static_cast<DerivedType *>(this)->increment();
213 return *static_cast<DerivedType *>(this);
214 }
215
218 {
219 DerivedType tmp(static_cast<DerivedType const&>(*this));
220 this->operator++();
221 return tmp;
222 }
223 };
224
235 template<class T1, class V1, class R1, class D,
236 class T2, class V2, class R2>
237 inline typename EnableIfInterOperable<T1,T2,bool>::type
240 {
241 if(std::is_convertible<T2,T1>::value)
242 return static_cast<const T1&>(lhs).equals(static_cast<const T2&>(rhs));
243 else
244 return static_cast<const T2&>(rhs).equals(static_cast<const T1&>(lhs));
245 }
246
257 template<class T1, class V1, class R1, class D,
258 class T2, class V2, class R2>
259 inline typename EnableIfInterOperable<T1,T2,bool>::type
262 {
263 if(std::is_convertible<T2,T1>::value)
264 return !static_cast<const T1&>(lhs).equals(static_cast<const T2&>(rhs));
265 else
266 return !static_cast<const T2&>(rhs).equals(static_cast<const T1&>(lhs));
267 }
268
273 template<class T, class V, class R = V&, class D = std::ptrdiff_t>
275 {
276
277 public:
278 /* type aliases required by C++ for iterators */
279 using iterator_category = std::bidirectional_iterator_tag;
280 using value_type = typename std::remove_const<V>::type;
281 using difference_type = D;
282 using pointer = V*;
283 using reference = R;
284
310 typedef T DerivedType;
311
315 typedef V Value;
316
320 typedef V* Pointer;
321
325 typedef D DifferenceType;
326
330 typedef R Reference;
331
334 {
335 return static_cast<DerivedType const*>(this)->dereference();
336 }
337
338 Pointer operator->() const
339 {
340 return &(static_cast<const DerivedType *>(this)->dereference());
341 }
342
345 {
346 static_cast<DerivedType *>(this)->increment();
347 return *static_cast<DerivedType *>(this);
348 }
349
352 {
353 DerivedType tmp(static_cast<DerivedType const&>(*this));
354 this->operator++();
355 return tmp;
356 }
357
358
361 {
362 static_cast<DerivedType *>(this)->decrement();
363 return *static_cast<DerivedType *>(this);
364 }
365
368 {
369 DerivedType tmp(static_cast<DerivedType const&>(*this));
370 this->operator--();
371 return tmp;
372 }
373 };
374
382 template<class T1, class V1, class R1, class D,
383 class T2, class V2, class R2>
384 inline typename std::enable_if<std::is_convertible<T2,T1>::value,bool>::type
387 {
388 return static_cast<const T1&>(lhs).equals(static_cast<const T2&>(rhs));
389 }
390
399 template<class T1, class V1, class R1, class D,
400 class T2, class V2, class R2>
401 inline
402 typename std::enable_if<std::is_convertible<T1,T2>::value && !std::is_convertible<T2,T1>::value,
403 bool>::type
406 {
407 return static_cast<const T2&>(rhs).equals(static_cast<const T1&>(lhs));
408 }
409
420 template<class T1, class V1, class R1, class D,
421 class T2, class V2, class R2>
422 inline typename EnableIfInterOperable<T1,T2,bool>::type
425 {
426 return !(lhs == rhs);
427 }
428
433 template<class T, class V, class R = V&, class D = std::ptrdiff_t>
435 {
436
437 public:
438 /* type aliases required by C++ for iterators */
439 using iterator_category = std::random_access_iterator_tag;
440 using value_type = typename std::remove_const<V>::type;
441 using difference_type = D;
442 using pointer = V*;
443 using reference = R;
444
478 typedef T DerivedType;
479
483 typedef V Value;
484
488 typedef V* Pointer;
489
493 typedef D DifferenceType;
494
498 typedef R Reference;
499
502 {
503 return static_cast<DerivedType const*>(this)->dereference();
504 }
505
506 Pointer operator->() const
507 {
508 return &(static_cast<const DerivedType *>(this)->dereference());
509 }
510
517 {
518 return static_cast<const DerivedType *>(this)->elementAt(n);
519 }
520
523 {
524 static_cast<DerivedType *>(this)->increment();
525 return *static_cast<DerivedType *>(this);
526 }
527
530 {
531 DerivedType tmp(static_cast<DerivedType const&>(*this));
532 this->operator++();
533 return tmp;
534 }
535
536 DerivedType& operator+=(DifferenceType n)
537 {
538 static_cast<DerivedType *>(this)->advance(n);
539 return *static_cast<DerivedType *>(this);
540 }
541
542 DerivedType operator+(DifferenceType n) const
543 {
544 DerivedType tmp(static_cast<DerivedType const&>(*this));
545 tmp.advance(n);
546 return tmp;
547 }
548
549
552 {
553 static_cast<DerivedType *>(this)->decrement();
554 return *static_cast<DerivedType *>(this);
555 }
556
559 {
560 DerivedType tmp(static_cast<DerivedType const&>(*this));
561 this->operator--();
562 return tmp;
563 }
564
565 DerivedType& operator-=(DifferenceType n)
566 {
567 static_cast<DerivedType *>(this)->advance(-n);
568 return *static_cast<DerivedType *>(this);
569 }
570
571 DerivedType operator-(DifferenceType n) const
572 {
573 DerivedType tmp(static_cast<DerivedType const&>(*this));
574 tmp.advance(-n);
575 return tmp;
576 }
577
578
579 };
580
591 template<class T1, class V1, class R1, class D,
592 class T2, class V2, class R2>
593 inline typename EnableIfInterOperable<T1,T2,bool>::type
596 {
597 if(std::is_convertible<T2,T1>::value)
598 return static_cast<const T1&>(lhs).equals(static_cast<const T2&>(rhs));
599 else
600 return static_cast<const T2&>(rhs).equals(static_cast<const T1&>(lhs));
601 }
602
613 template<class T1, class V1, class R1, class D,
614 class T2, class V2, class R2>
615 inline typename EnableIfInterOperable<T1,T2,bool>::type
618 {
619 if(std::is_convertible<T2,T1>::value)
620 return !static_cast<const T1&>(lhs).equals(static_cast<const T2&>(rhs));
621 else
622 return !static_cast<const T2&>(rhs).equals(static_cast<const T1&>(lhs));
623 }
624
635 template<class T1, class V1, class R1, class D,
636 class T2, class V2, class R2>
640 {
641 if(std::is_convertible<T2,T1>::value)
642 return static_cast<const T1&>(lhs).distanceTo(static_cast<const T2&>(rhs))>0;
643 else
644 return static_cast<const T2&>(rhs).distanceTo(static_cast<const T1&>(lhs))<0;
645 }
646
647
658 template<class T1, class V1, class R1, class D,
659 class T2, class V2, class R2>
663 {
664 if(std::is_convertible<T2,T1>::value)
665 return static_cast<const T1&>(lhs).distanceTo(static_cast<const T2&>(rhs))>=0;
666 else
667 return static_cast<const T2&>(rhs).distanceTo(static_cast<const T1&>(lhs))<=0;
668 }
669
670
681 template<class T1, class V1, class R1, class D,
682 class T2, class V2, class R2>
683 inline typename EnableIfInterOperable<T1,T2,bool>::type
686 {
687 if(std::is_convertible<T2,T1>::value)
688 return static_cast<const T1&>(lhs).distanceTo(static_cast<const T2&>(rhs))<0;
689 else
690 return static_cast<const T2&>(rhs).distanceTo(static_cast<const T1&>(lhs))>0;
691 }
692
703 template<class T1, class V1, class R1, class D,
704 class T2, class V2, class R2>
705 inline typename EnableIfInterOperable<T1,T2,bool>::type
708 {
709 if(std::is_convertible<T2,T1>::value)
710 return static_cast<const T1&>(lhs).distanceTo(static_cast<const T2&>(rhs))<=0;
711 else
712 return static_cast<const T2&>(rhs).distanceTo(static_cast<const T1&>(lhs))>=0;
713 }
714
725 template<class T1, class V1, class R1, class D,
726 class T2, class V2, class R2>
727 inline typename EnableIfInterOperable<T1,T2,D>::type
730 {
731 if(std::is_convertible<T2,T1>::value)
732 return -static_cast<const T1&>(lhs).distanceTo(static_cast<const T2&>(rhs));
733 else
734 return static_cast<const T2&>(rhs).distanceTo(static_cast<const T1&>(lhs));
735 }
736
737
748 template<class ProxyType>
750 {
751 public:
752 constexpr ProxyArrowResult(ProxyType&& p)
753 noexcept(std::is_nothrow_constructible_v<ProxyType, ProxyType&&>)
754 : p_(std::move(p))
755 {}
756
757 constexpr ProxyArrowResult(const ProxyType& p)
758 noexcept(std::is_nothrow_constructible_v<ProxyType, const ProxyType&>)
759 : p_(p)
760 {}
761
762 constexpr const ProxyType* operator->() const noexcept
763 {
764 return &p_;
765 }
766
767 constexpr ProxyType* operator->() noexcept
768 {
769 return &p_;
770 }
771
772 private:
773 ProxyType p_;
774 };
775
776
786 {
787
789 template<class It>
790 static constexpr auto baseIterator(It&& it) noexcept
791 -> decltype(it.baseIterator())
792 {
793 return it.baseIterator();
794 }
795
797 template<class It>
798 static constexpr auto derived(It&& it) noexcept
799 -> decltype(it.derived())
800 {
801 return it.derived();
802 }
803
804 };
805
806
807
808 namespace Impl::Concepts {
809
810 using namespace Dune::Concept;
811
812 template<class R>
813 struct BaseIterDereferenceOp
814 {
815 template<class It>
816 auto require(const It& it) -> decltype(
817 *(IteratorFacadeAccess::baseIterator(it)),
818 requireConvertible<decltype(*(IteratorFacadeAccess::baseIterator(it))), R>()
819 );
820 };
821
822 struct IterEqualsOp
823 {
824 template<class It1, class It2>
825 auto require(const It1& it1, const It2& it2) -> decltype(
826 requireConvertible<bool>(it1 == it2)
827 );
828 };
829
830 struct BaseIterEqualsOp
831 {
832 template<class It1, class It2>
833 auto require(const It1& it1, const It2& it2) -> decltype(
834 Dune::Concept::requireConvertible<bool>(IteratorFacadeAccess::baseIterator(it1) == IteratorFacadeAccess::baseIterator(it2))
835 );
836 };
837
838 struct BaseIterIncrementOp
839 {
840 template<class It>
841 auto require(It it) -> decltype(
842 ++(IteratorFacadeAccess::baseIterator(it))
843 );
844 };
845
846 struct BaseIterDecrementOp
847 {
848 template<class It>
849 auto require(It it) -> decltype(
850 --(IteratorFacadeAccess::baseIterator(it))
851 );
852 };
853
854 template<class D>
855 struct IterAdvanceOp
856 {
857 template<class It>
858 auto require(It it) -> decltype(
859 it += std::declval<D>()
860 );
861 };
862
863 template<class D>
864 struct BaseIterAdvanceOp
865 {
866 template<class It>
867 auto require(It it) -> decltype(
868 IteratorFacadeAccess::baseIterator(it) += std::declval<D>()
869 );
870 };
871
872 template<class D>
873 struct IterDistanceOp
874 {
875 template<class It1, class It2>
876 auto require(const It1& it1, const It2& it2) -> decltype(
877 Dune::Concept::requireConvertible<D>(it1 - it2)
878 );
879 };
880
881 template<class D>
882 struct BaseIterDistanceOp
883 {
884 template<class It1, class It2>
885 auto require(const It1& it1, const It2& it2) -> decltype(
886 Dune::Concept::requireConvertible<D>(IteratorFacadeAccess::baseIterator(it1) - IteratorFacadeAccess::baseIterator(it2))
887 );
888 };
889
890 } // namespace Impl::Concept
891
892
893
1051 template<class It, class C, class V, class R = V&, class P = V*, class D = std::ptrdiff_t>
1053 {
1054 static constexpr bool isBidirectional = std::is_convertible_v<C, std::bidirectional_iterator_tag>;
1055 static constexpr bool isRandomAccess = std::is_convertible_v<C, std::random_access_iterator_tag>;
1056
1057 // We make IteratorFacadeAccess a friend to allow forwarding of the derived()
1058 // methods to the free operators instead of havin to do raw casts there.
1059 // This allows to encapsulate all casts within IteratorFacade itself.
1060 friend IteratorFacadeAccess;
1061
1062 protected:
1063
1066
1068 constexpr const DerivedIterator& derived() const
1069 {
1070 return static_cast<const DerivedIterator&>(*this);
1071 }
1072
1075 {
1076 return static_cast<DerivedIterator&>(*this);
1077 }
1078
1079 public:
1080
1081 // Standard types of of C++ iterators
1082 using iterator_category = C;
1083 using value_type = typename std::remove_const<V>::type;
1084 using reference = R;
1085 using pointer = P;
1086 using difference_type = D;
1087
1088 // Corresponding Dune typedefs
1089 using Value = value_type;
1090 using Reference = reference;
1091 using Pointer = pointer;
1092 using DifferenceType = difference_type;
1093
1094 // Only defined to do static assertions.
1096 {
1097 static_assert(std::is_signed_v<difference_type>,
1098 "Type used as difference_type must be signed");
1099 const DerivedIterator& constDerived = derived();
1100 static_assert(std::is_convertible_v<decltype(*constDerived), reference>,
1101 "Derived class does not implement `*it` or `*(it.baseIterator())` for const `it` required by IteratorFacade<..., std::forward_iterator_tag, ...>.");
1102 static_assert(std::is_convertible_v<decltype(++derived()), DerivedIterator&>,
1103 "Derived class does not implement `++it`, `++(it.baseIterator())`, or `it+=1` for mutable `it` required by IteratorFacade<..., std::forward_iterator_tag, ...>.");
1104 static_assert(std::is_convertible_v<decltype(constDerived==constDerived), bool>,
1105 "Derived class does not implement `it1==it2` or `it1.baseIterator()==it2.baseIterator()` for const `it1` and `it2` required by IteratorFacade<..., std::forward_iterator_tag, ...>.");
1106 if constexpr (isBidirectional)
1107 static_assert(std::is_convertible_v<decltype(--derived()), DerivedIterator&>,
1108 "Derived class does not implement `--it`, `--(it.baseIterator())`, or `it-=1` for mutable `it` required by IteratorFacade<..., std::bidirectional_iterator_tag, ...>.");
1109 if constexpr (isRandomAccess)
1110 {
1111 static_assert(std::is_convertible_v<decltype(derived()+=std::declval<difference_type>()), DerivedIterator&>,
1112 "Derived class does not implement `it+=` or `it.baseIterator()+=` for mutable `it` required by IteratorFacade<..., std::random_access_iterator_tag, ...>.");
1113 static_assert(std::is_convertible_v<decltype(constDerived-constDerived), difference_type>,
1114 "Derived class does not implement `it1-it2` or `it1.baseIterator()-it2.baseIterator()` for const `it1` and `it2` required by IteratorFacade<..., std::random_access_iterator_tag, ...>.");
1115 }
1116 }
1117
1119 constexpr decltype(auto) operator*() const
1120 {
1121 if constexpr (Dune::models<Impl::Concepts::BaseIterDereferenceOp<reference>, DerivedIterator>())
1122 return *(IteratorFacadeAccess::baseIterator(derived()));
1123 else
1124 static_assert(AlwaysFalse<It>::value,
1125 "Derived class does not implement `*it` or `*(it.baseIterator())` for const `it` required by IteratorFacade<..., std::forward_iterator_tag, ...>.");
1126 }
1127
1129 constexpr pointer operator->() const
1130 {
1131 if constexpr (std::is_pointer_v<pointer>)
1132 return std::addressof(*derived());
1133 else
1134 return pointer(*derived());
1135 }
1136
1138 constexpr decltype(auto) operator++()
1139 {
1140 if constexpr (Dune::models<Impl::Concepts::BaseIterIncrementOp, DerivedIterator>())
1141 {
1142 ++(IteratorFacadeAccess::baseIterator(derived()));
1143 return derived();
1144 }
1145 else if constexpr (Dune::models<Impl::Concepts::IterAdvanceOp<difference_type>, DerivedIterator>())
1146 {
1147 derived() += 1;
1148 return derived();
1149 }
1150 else
1151 static_assert(AlwaysFalse<It>::value,
1152 "Derived class does not implement `++it`, `++(it.baseIterator())`, or `it+=1` for mutable `it` required by IteratorFacade<..., std::forward_iterator_tag, ...>.");
1153 }
1154
1157 {
1158 DerivedIterator tmp(derived());
1159 this->operator++();
1160 return tmp;
1161 }
1162
1168 template<bool dummy=true, std::enable_if_t<isBidirectional and dummy, int> =0>
1169 constexpr decltype(auto) operator--()
1170 {
1171 if constexpr (Dune::models<Impl::Concepts::BaseIterDecrementOp, DerivedIterator>())
1172 {
1173 --(IteratorFacadeAccess::baseIterator(derived()));
1174 return derived();
1175 }
1176 else if constexpr (Dune::models<Impl::Concepts::IterAdvanceOp<difference_type>, DerivedIterator>())
1177 {
1178 derived() -= 1;
1179 return derived();
1180 }
1181 else
1182 static_assert(AlwaysFalse<It>::value,
1183 "Derived class does not implement `--it`, `--(it.baseIterator())`, or `it-=1` for mutable `it` required by IteratorFacade<..., std::bidirectional_iterator_tag, ...>.");
1184 }
1185
1191 template<bool dummy=true, std::enable_if_t<isBidirectional and dummy, int> =0>
1193 {
1194 DerivedIterator tmp(derived());
1195 this->operator--();
1196 return tmp;
1197 }
1198
1206 template<bool dummy=true, std::enable_if_t<isRandomAccess and dummy, int> =0>
1207 constexpr reference operator[](difference_type n) const
1208 {
1209 return *(derived()+n);
1210 }
1211
1217 template<bool dummy=true, std::enable_if_t<isRandomAccess and dummy, int> =0>
1218 constexpr decltype(auto) operator+=(difference_type n)
1219 {
1220 if constexpr (Dune::models<Impl::Concepts::BaseIterAdvanceOp<difference_type>, DerivedIterator>())
1221 {
1222 IteratorFacadeAccess::baseIterator(derived()) += n;
1223 return derived();
1224 }
1225 else
1226 static_assert(AlwaysFalse<It>::value,
1227 "Derived class does not implement `it+=` or `it.baseIterator()+=` for mutable `it` required by IteratorFacade<..., std::random_access_iterator_tag, ...>.");
1228 }
1229
1235 template<bool dummy=true, std::enable_if_t<isRandomAccess and dummy, int> =0>
1236 constexpr DerivedIterator operator+(difference_type n) const
1237 {
1238 DerivedIterator tmp(derived());
1239 tmp += n;
1240 return tmp;
1241 }
1242
1248 template<bool dummy=true, std::enable_if_t<isRandomAccess and dummy, int> =0>
1249 friend constexpr DerivedIterator operator+(difference_type n, const IteratorFacade& it)
1250 {
1251 DerivedIterator tmp(it.derived());
1252 tmp += n;
1253 return tmp;
1254 }
1255
1261 template<bool dummy=true, std::enable_if_t<isRandomAccess and dummy, int> =0>
1262 constexpr DerivedIterator& operator-=(difference_type n)
1263 {
1264 derived() += (-n);
1265 return derived();
1266 }
1267
1273 template<bool dummy=true, std::enable_if_t<isRandomAccess and dummy, int> =0>
1274 constexpr DerivedIterator operator-(difference_type n) const
1275 {
1276 DerivedIterator tmp(derived());
1277 tmp -= n;
1278 return tmp;
1279 }
1280
1281 };
1282
1283
1284
1295 template<class T1, class T2, class C, class V1, class V2, class R1, class R2, class P1, class P2, class D1, class D2>
1297 {
1298 const T1& derivedIt1 = IteratorFacadeAccess::derived(it1);
1299 const T2& derivedIt2 = IteratorFacadeAccess::derived(it2);
1300 if constexpr (Dune::models<Impl::Concepts::BaseIterEqualsOp, T1, T2>())
1301 return IteratorFacadeAccess::baseIterator(derivedIt1) == IteratorFacadeAccess::baseIterator(derivedIt2);
1302 else
1303 static_assert(AlwaysFalse<T1>::value,
1304 "Derived class does not implement `it1==it2` or `it1.baseIterator()==it2.baseIterator()` for const `it1` and `it2` required by IteratorFacade<..., std::forward_iterator_tag, ...>.");
1305 }
1306
1314 template<class T1, class T2, class C, class V1, class V2, class R1, class R2, class P1, class P2, class D1, class D2,
1315 std::enable_if_t< Dune::models<Impl::Concepts::IterEqualsOp,T1, T2>() , int> =0>
1317 {
1318 const T1& derivedIt1 = IteratorFacadeAccess::derived(it1);
1319 const T2& derivedIt2 = IteratorFacadeAccess::derived(it2);
1320 return not(derivedIt1 == derivedIt2);
1321 }
1322
1333 template<class T1, class T2, class C, class V1, class V2, class R1, class R2, class P1, class P2, class D>
1334 constexpr auto operator-(const IteratorFacade<T1,C,V1,R1,P1,D>& it1, const IteratorFacade<T2,C,V2,R2,P2,D>& it2)
1335 {
1336 const T1& derivedIt1 = IteratorFacadeAccess::derived(it1);
1337 const T2& derivedIt2 = IteratorFacadeAccess::derived(it2);
1338 if constexpr (Dune::models<Impl::Concepts::BaseIterDistanceOp<D>,T1, T2>())
1339 return D(IteratorFacadeAccess::baseIterator(derivedIt1) - IteratorFacadeAccess::baseIterator(derivedIt2));
1340 else
1341 static_assert(AlwaysFalse<T1>::value,
1342 "Derived class does not implement `it1-it2` or `it1.baseIterator()-it2.baseIterator()` for const `it1` and `it2` required by IteratorFacade<..., std::random_access_iterator_tag, ...>.");
1343 }
1344
1352 template<class T1, class T2, class C, class V1, class V2, class R1, class R2, class P1, class P2, class D1, class D2,
1353 std::enable_if_t< Dune::models<Impl::Concepts::IterDistanceOp<D1>,T1, T2>() , int> =0>
1354 constexpr bool operator<(const IteratorFacade<T1,C,V1,R1,P1,D1>& it1, const IteratorFacade<T2,C,V2,R2,P2,D2>& it2)
1355 {
1356 const T1& derivedIt1 = IteratorFacadeAccess::derived(it1);
1357 const T2& derivedIt2 = IteratorFacadeAccess::derived(it2);
1358 return (derivedIt1 - derivedIt2) < D1(0);
1359 }
1360
1368 template<class T1, class T2, class C, class V1, class V2, class R1, class R2, class P1, class P2, class D1, class D2,
1369 std::enable_if_t< Dune::models<Impl::Concepts::IterDistanceOp<D1>,T1, T2>() , int> =0>
1370 constexpr bool operator<=(const IteratorFacade<T1,C,V1,R1,P1,D1>& it1, const IteratorFacade<T2,C,V2,R2,P2,D2>& it2)
1371 {
1372 const T1& derivedIt1 = IteratorFacadeAccess::derived(it1);
1373 const T2& derivedIt2 = IteratorFacadeAccess::derived(it2);
1374 return (derivedIt1 - derivedIt2) <= D1(0);
1375 }
1376
1384 template<class T1, class T2, class C, class V1, class V2, class R1, class R2, class P1, class P2, class D1, class D2,
1385 std::enable_if_t< Dune::models<Impl::Concepts::IterDistanceOp<D1>,T1, T2>() , int> =0>
1386 constexpr bool operator>(const IteratorFacade<T1,C,V1,R1,P1,D1>& it1, const IteratorFacade<T2,C,V2,R2,P2,D2>& it2)
1387 {
1388 const T1& derivedIt1 = IteratorFacadeAccess::derived(it1);
1389 const T2& derivedIt2 = IteratorFacadeAccess::derived(it2);
1390 return (derivedIt1 - derivedIt2) > D1(0);
1391 }
1392
1400 template<class T1, class T2, class C, class V1, class V2, class R1, class R2, class P1, class P2, class D1, class D2,
1401 std::enable_if_t< Dune::models<Impl::Concepts::IterDistanceOp<D1>,T1, T2>() , int> =0>
1402 constexpr bool operator>=(const IteratorFacade<T1,C,V1,R1,P1,D1>& it1, const IteratorFacade<T2,C,V2,R2,P2,D2>& it2)
1403 {
1404 const T1& derivedIt1 = IteratorFacadeAccess::derived(it1);
1405 const T2& derivedIt2 = IteratorFacadeAccess::derived(it2);
1406 return (derivedIt1 - derivedIt2) >= D1(0);
1407 }
1408
1409
1410
1412}
1413#endif
Facade class for stl conformant bidirectional iterators.
Definition: iteratorfacades.hh:275
Reference operator*() const
Dereferencing operator.
Definition: iteratorfacades.hh:333
T DerivedType
The type of derived iterator.
Definition: iteratorfacades.hh:310
DerivedType & operator--()
Preincrement operator.
Definition: iteratorfacades.hh:360
DerivedType & operator++()
Preincrement operator.
Definition: iteratorfacades.hh:344
V * Pointer
The pointer to the Value.
Definition: iteratorfacades.hh:320
R Reference
The type of the reference to the values accessed.
Definition: iteratorfacades.hh:330
DerivedType operator++(int)
Postincrement operator.
Definition: iteratorfacades.hh:351
D DifferenceType
The type of the difference between two positions.
Definition: iteratorfacades.hh:325
DerivedType operator--(int)
Postincrement operator.
Definition: iteratorfacades.hh:367
V Value
The type of value accessed through the iterator.
Definition: iteratorfacades.hh:315
Base class for stl conformant forward iterators.
Definition: iteratorfacades.hh:142
DerivedType & operator++()
Preincrement operator.
Definition: iteratorfacades.hh:210
D DifferenceType
The type of the difference between two positions.
Definition: iteratorfacades.hh:191
R Reference
The type of the reference to the values accessed.
Definition: iteratorfacades.hh:196
T DerivedType
The type of derived iterator.
Definition: iteratorfacades.hh:176
V Value
The type of value accessed through the iterator.
Definition: iteratorfacades.hh:181
DerivedType operator++(int)
Postincrement operator.
Definition: iteratorfacades.hh:217
V * Pointer
The pointer to the Value.
Definition: iteratorfacades.hh:186
Reference operator*() const
Dereferencing operator.
Definition: iteratorfacades.hh:199
CRTP-Mixing class for stl conformant iterators of given iterator category.
Definition: iteratorfacades.hh:1053
constexpr DerivedIterator operator--(int)
Postdecrement operator.
Definition: iteratorfacades.hh:1192
constexpr pointer operator->() const
Arrow access to members of referenced value.
Definition: iteratorfacades.hh:1129
constexpr DerivedIterator operator+(difference_type n) const
Create iterator incremented by given value.
Definition: iteratorfacades.hh:1236
constexpr DerivedIterator operator++(int)
Postincrement operator.
Definition: iteratorfacades.hh:1156
constexpr DerivedIterator & derived()
Cast of *this to DerivedIterator type.
Definition: iteratorfacades.hh:1074
It DerivedIterator
The derived iterator type.
Definition: iteratorfacades.hh:1065
constexpr DerivedIterator & operator-=(difference_type n)
Decrement iterator by given value.
Definition: iteratorfacades.hh:1262
constexpr decltype(auto) operator--()
Predecrement operator.
Definition: iteratorfacades.hh:1169
constexpr reference operator[](difference_type n) const
Dereference element with given offset form this iterator.
Definition: iteratorfacades.hh:1207
constexpr const DerivedIterator & derived() const
Cast of *this to const DerivedIterator type.
Definition: iteratorfacades.hh:1068
friend constexpr DerivedIterator operator+(difference_type n, const IteratorFacade &it)
Create iterator incremented by given value.
Definition: iteratorfacades.hh:1249
constexpr decltype(auto) operator++()
Preincrement operator.
Definition: iteratorfacades.hh:1138
constexpr DerivedIterator operator-(difference_type n) const
Create iterator decremented by given value.
Definition: iteratorfacades.hh:1274
Helper to mimic a pointer for proxy objects.
Definition: iteratorfacades.hh:750
Base class for stl conformant forward iterators.
Definition: iteratorfacades.hh:435
DerivedType operator--(int)
Postdecrement operator.
Definition: iteratorfacades.hh:558
Reference operator*() const
Dereferencing operator.
Definition: iteratorfacades.hh:501
DerivedType & operator++()
Preincrement operator.
Definition: iteratorfacades.hh:522
D DifferenceType
The type of the difference between two positions.
Definition: iteratorfacades.hh:493
DerivedType & operator--()
Predecrement operator.
Definition: iteratorfacades.hh:551
Reference operator[](DifferenceType n) const
Get the element n positions from the current one.
Definition: iteratorfacades.hh:516
T DerivedType
The type of derived iterator.
Definition: iteratorfacades.hh:478
V * Pointer
The pointer to the Value.
Definition: iteratorfacades.hh:488
DerivedType operator++(int)
Postincrement operator.
Definition: iteratorfacades.hh:529
V Value
The type of value accessed through the iterator.
Definition: iteratorfacades.hh:483
R Reference
The type of the reference to the values accessed.
Definition: iteratorfacades.hh:498
Infrastructure for concepts.
constexpr auto equals(T1 &&t1, T2 &&t2)
Equality comparison.
Definition: hybridutilities.hh:587
constexpr decltype(auto) elementAt(Container &&c, Index &&i)
Get element at given position from container.
Definition: hybridutilities.hh:126
EnableIfInterOperable< T1, T2, bool >::type operator<(const RandomAccessIteratorFacade< T1, V1, R1, D > &lhs, const RandomAccessIteratorFacade< T2, V2, R2, D > &rhs)
Comparison operator.
Definition: iteratorfacades.hh:638
EnableIfInterOperable< T1, T2, bool >::type operator>(const RandomAccessIteratorFacade< T1, V1, R1, D > &lhs, const RandomAccessIteratorFacade< T2, V2, R2, D > &rhs)
Comparison operator.
Definition: iteratorfacades.hh:684
EnableIfInterOperable< T1, T2, bool >::type operator<=(const RandomAccessIteratorFacade< T1, V1, R1, D > &lhs, const RandomAccessIteratorFacade< T2, V2, R2, D > &rhs)
Comparison operator.
Definition: iteratorfacades.hh:661
EnableIfInterOperable< T1, T2, bool >::type operator==(const ForwardIteratorFacade< T1, V1, R1, D > &lhs, const ForwardIteratorFacade< T2, V2, R2, D > &rhs)
Checks for equality.
Definition: iteratorfacades.hh:238
EnableIfInterOperable< T1, T2, bool >::type operator>=(const RandomAccessIteratorFacade< T1, V1, R1, D > &lhs, const RandomAccessIteratorFacade< T2, V2, R2, D > &rhs)
Comparison operator.
Definition: iteratorfacades.hh:706
EnableIfInterOperable< T1, T2, bool >::type operator!=(const ForwardIteratorFacade< T1, V1, R1, D > &lhs, const ForwardIteratorFacade< T2, V2, R2, D > &rhs)
Checks for inequality.
Definition: iteratorfacades.hh:260
Namespace for concepts.
Definition: concept.hh:34
Dune namespace.
Definition: alignedallocator.hh:13
template which always yields a false value
Definition: typetraits.hh:124
Enable typedef if two types are interoperable.
Definition: typetraits.hh:81
This class encapsulates access of IteratorFacade.
Definition: iteratorfacades.hh:786
Traits for type conversions and type information.
Creative Commons License   |  Legal Statements / Impressum  |  Hosted by TU Dresden  |  generated with Hugo v0.111.3 (Dec 21, 23:30, 2024)