LIEF: Library to Instrument Executable Formats Version 0.17.0
Loading...
Searching...
No Matches
iterators.hpp
Go to the documentation of this file.
1/* Copyright 2017 - 2024 R. Thomas
2 * Copyright 2017 - 2024 Quarkslab
3 * Copyright 2017 - 2021, NVIDIA CORPORATION. All rights reserved.
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 */
17#ifndef LIEF_ITERATORS_H
18#define LIEF_ITERATORS_H
19#include <cmath>
20#include <cstddef>
21#include <cassert>
22#include <iterator>
23#include <functional>
24#include <algorithm>
25#include <type_traits>
26#include <vector>
27
28namespace LIEF {
29
30template<class T>
31using decay_t = typename std::decay<T>::type;
32
33template<class T>
34using add_const_t = typename std::add_const<T>::type;
35
36template<class T>
37using remove_const_t = typename std::remove_const<T>::type;
38
39template< class T >
40using add_lvalue_reference_t = typename std::add_lvalue_reference<T>::type;
41
42template<class T, typename U = typename decay_t<T>::value_type,
45 class ITERATOR_T = typename decay_t<T>::iterator>
47 public:
48 using iterator_category = std::bidirectional_iterator_tag;
50 using difference_type = ptrdiff_t;
51 using pointer = typename std::remove_pointer<U>::type*;
52 using reference = typename std::remove_pointer<U>::type&;
53
54 using container_type = T; // e.g. std::vector<Section*>&
55 using DT_VAL = U; // e.g. Section*
56 using DT = decay_t<T>; // e.g. std::vector<Section>
59
60 ref_iterator(T container) :
61 container_{std::forward<T>(container)}
62 {
63 it_ = std::begin(container_);
64 }
65
67 container_{copy.container_},
68 it_{std::begin(container_)},
69 distance_{copy.distance_}
70 {
71 std::advance(it_, distance_);
72 }
73
74
76 swap(other);
77 return *this;
78 }
79
80 void swap(ref_iterator& other) noexcept {
81 std::swap(const_cast<add_lvalue_reference_t<remove_const_t<DT>>>(container_),
82 const_cast<add_lvalue_reference_t<remove_const_t<DT>>>(other.container_));
83 std::swap(it_, other.it_);
84 std::swap(distance_, other.distance_);
85 }
86
87
89 it_ = std::next(it_);
90 distance_++;
91 return *this;
92 }
93
95 ref_iterator retval = *this;
96 ++(*this);
97 return retval;
98 }
99
101 if (it_ != std::begin(container_)) {
102 it_ = std::prev(it_);
103 distance_--;
104 }
105 return *this;
106 }
107
109 ref_iterator retval = *this;
110 --(*this);
111 return retval;
112 }
113
114
116 std::advance(it_, movement);
117 distance_ += movement;
118 return *this;
119 }
120
121
123 return (*this) += -movement;
124 }
125
126
127 typename std::enable_if<!std::is_const<ref_t>::value, remove_const_t<ref_t>>::type
128 operator[](size_t n) {
129 return const_cast<remove_const_t<ref_t>>(static_cast<const ref_iterator*>(this)->operator[](n));
130 }
131
132
134 assert(n < size() && "integrity error: out of bound");
135
136 auto* no_const_this = const_cast<ref_iterator*>(this);
137
138 typename ref_iterator::difference_type saved_dist = std::distance(std::begin(no_const_this->container_), no_const_this->it_);
139 no_const_this->it_ = std::begin(no_const_this->container_);
140 std::advance(no_const_this->it_, n);
141
142 auto&& v = const_cast<add_const_t<ref_t>>(no_const_this->operator*());
143
144 no_const_this->it_ = std::begin(no_const_this->container_);
145 std::advance(no_const_this->it_, saved_dist);
146
147 return v;
148 }
149
151 ref_iterator tmp = *this;
152 return tmp += n;
153 }
154
155
157 ref_iterator tmp = *this;
158 return tmp -= n;
159 }
160
161
163 return distance_ - rhs.distance_;
164 }
165
166 bool operator<(const ref_iterator& rhs) const {
167 return (rhs - *this) > 0;
168 }
169
170
171 bool operator>(const ref_iterator& rhs) const {
172 return rhs < *this;
173 }
174
175
176 bool operator>=(const ref_iterator& rhs) const {
177 return !(*this < rhs);
178 }
179
180
181 bool operator<=(const ref_iterator& rhs) const {
182 return !(*this > rhs);
183 }
184
186 return container_;
187 }
188
190 return begin();
191 }
192
194 ref_iterator it = ref_iterator{container_};
195 it.it_ = std::end(it.container_);
196 it.distance_ = it.size();
197 return it;
198 }
199
201 return end();
202 }
203
204 bool operator==(const ref_iterator& other) const {
205 return (size() == other.size() && distance_ == other.distance_);
206 }
207
208 bool operator!=(const ref_iterator& other) const {
209 return !(*this == other);
210 }
211
212 size_t size() const {
213 return container_.size();
214 }
215
216 bool empty() const {
217 return container_.empty();
218 }
219
220 typename std::enable_if<!std::is_const<ref_t>::value, remove_const_t<ref_t>>::type
222 return const_cast<remove_const_t<ref_t>>(static_cast<const ref_iterator*>(this)->operator*());
223 }
224
225 template<typename V = DT_VAL>
226 typename std::enable_if<std::is_pointer<V>::value, add_const_t<ref_t>>::type
227 operator*() const {
228 assert(*it_ && "integrity error: nullptr");
229 return const_cast<add_const_t<ref_t>>(static_cast<ref_t>(**it_));
230 }
231
232 template<typename V = DT_VAL>
233 typename std::enable_if<!std::is_pointer<V>::value, add_const_t<ref_t>>::type
234 operator*() const {
235 return const_cast<add_const_t<ref_t>>(*(it_));
236 }
237
238
239 typename std::enable_if<!std::is_const<pointer_t>::value, pointer_t>::type
241 return const_cast<remove_const_t<pointer_t>>(static_cast<const ref_iterator*>(this)->operator->());
242 }
243
245 return const_cast<add_const_t<pointer_t>>(&(operator*()));
246 }
247
248 protected:
249 T container_;
250 ITERATOR_T it_;
251 typename ref_iterator::difference_type distance_{};
252};
253
254template<class T, typename U = typename decay_t<T>::value_type, class CT = typename std::add_const<T>::type>
258
259template<class T, typename U = typename decay_t<T>::value_type,
262 class ITERATOR_T = typename decay_t<T>::iterator>
264
265 public:
266 using iterator_category = std::forward_iterator_tag;
268 using difference_type = ptrdiff_t;
269 using pointer = typename std::remove_pointer<U>::type*;
270 using reference = typename std::remove_pointer<U>::type&;
271
272 using container_type = T;
273 using DT_VAL = U;
274 using DT = decay_t<T>;
277 using filter_t = std::function<bool (const typename DT::value_type&)>;
278
279 filter_iterator(T container, filter_t filter) :
280 container_{std::forward<T>(container)},
281 filters_{}
282 {
283
284 it_ = std::begin(container_);
285
286 filters_.push_back(filter),
287 it_ = std::begin(container_);
288
289 if (it_ != std::end(container_)) {
290 if (!std::all_of(std::begin(filters_), std::end(filters_), [this] (const filter_t& f) {return f(*it_);})) {
291 next();
292 }
293 }
294 }
295
296 filter_iterator(T container, const std::vector<filter_t>& filters) :
297 container_{std::forward<T>(container)},
298 filters_{filters}
299 {
300
301 it_ = std::begin(container_);
302
303 if (it_ != std::end(container_)) {
304 if (!std::all_of(std::begin(filters_), std::end(filters_), [this] (const filter_t& f) {return f(*it_);})) {
305 next();
306 }
307 }
308 }
309
310 filter_iterator(T container) :
311 container_{std::forward<T>(container)},
312 filters_{}
313 {
314 it_ = std::begin(container_);
315 }
316
318 container_{copy.container_},
319 it_{std::begin(container_)},
320 filters_{copy.filters_},
321 distance_{copy.distance_}
322 {
323 std::advance(it_, distance_);
324 }
325
327 swap(other);
328 return *this;
329 }
330
331 void swap(filter_iterator& other) noexcept {
332 std::swap(const_cast<remove_const_t<DT>&>(container_), const_cast<remove_const_t<DT>&>(other.container_));
333 std::swap(it_, other.it_);
334 std::swap(filters_, other.filters_);
335 std::swap(size_c_, other.size_c_);
336 std::swap(distance_, other.distance_);
337 }
338
339
341 filters_.push_back(func);
342 size_c_ = 0;
343 return *this;
344 }
345
347 next();
348 return *this;
349 }
350
352 filter_iterator retval = *this;
353 ++(*this);
354 return retval;
355 }
356
358 return {container_, filters_};
359 }
360
362 return begin();
363 }
364
366 // we don't need filter for the end iterator
367 filter_iterator it_end{container_};
368
369 it_end.it_ = it_end.container_.end();
370 it_end.distance_ = it_end.container_.size();
371
372 return it_end;
373 }
374
376 return end();
377 }
378
379 typename std::enable_if<!std::is_const<ref_t>::value, remove_const_t<ref_t>>::type
381 return const_cast<remove_const_t<ref_t>>(static_cast<const filter_iterator*>(this)->operator*());
382 }
383
384 template<typename V = DT_VAL>
385 typename std::enable_if<std::is_pointer<V>::value, add_const_t<ref_t>>::type
386 operator*() const {
387 assert(*it_ && "integrity error: nullptr");
388 return const_cast<add_const_t<ref_t>>(static_cast<ref_t>(**it_));
389 }
390
391 template<typename V = DT_VAL>
392 typename std::enable_if<!std::is_pointer<V>::value, add_const_t<ref_t>>::type
393 operator*() const {
394 return const_cast<add_const_t<ref_t>>(*(it_));
395 }
396
397
398 typename std::enable_if<!std::is_const<ref_t>::value, remove_const_t<ref_t>>::type
399 operator[](size_t n) {
400 return const_cast<remove_const_t<ref_t>>(static_cast<const filter_iterator*>(this)->operator[](n));
401 }
402
404 assert(n < size() && "integrity error: out of bound");
405
406 auto it = begin();
407 std::advance(it, n);
408 return const_cast<add_const_t<ref_t>>(*it);
409 }
410
411
412 typename std::enable_if<!std::is_const<pointer_t>::value, pointer_t>::type
414 return const_cast<remove_const_t<pointer_t>>(static_cast<const filter_iterator*>(this)->operator->());
415 }
416
418 return const_cast<add_const_t<pointer_t>>(&(operator*()));
419 }
420
421 size_t size() const {
422 if (filters_.empty()) {
423 return container_.size();
424 }
425
426 if (size_c_ > 0) {
427 return size_c_;
428 }
429 filter_iterator it = begin();
430 size_t size = 0;
431
432 auto end_iter = std::end(it);
433 for (; it != end_iter; ++it) ++size;
434 size_c_ = size;
435 return size_c_;
436 }
437
438
439 bool empty() const {
440 return size() == 0;
441 }
442
443
444 bool operator==(const filter_iterator& other) const {
445 return (container_.size() == other.container_.size() && distance_ == other.distance_);
446 }
447
448 bool operator!=(const filter_iterator& other) const {
449 return !(*this == other);
450 }
451
452 protected:
453 void next() {
454 if (it_ == std::end(container_)) {
455 distance_ = container_.size();
456 return;
457 }
458
459 do {
460 it_ = std::next(it_);
461 distance_++;
462 } while(it_ != std::end(container_) &&
463 !std::all_of(std::begin(filters_), std::end(filters_),
464 [this] (const filter_t& f) { return f(*it_); }));
465
466 }
467
468
469 mutable size_t size_c_ = 0;
470 T container_;
471 ITERATOR_T it_;
472 std::vector<filter_t> filters_;
473 typename filter_iterator::difference_type distance_ = 0;
474};
475template<class T, typename U = typename decay_t<T>::value_type,
478 class CT = typename std::add_const<T>::type>
480
481// ----------------------------------------------------------------------------
482// This part is taken from LLVM
483// ----------------------------------------------------------------------------
484
485template <typename IteratorT>
487 public:
488 using IteratorTy = IteratorT;
489 iterator_range(IteratorT&& it_begin, IteratorT&& it_end)
490 : begin_(std::forward<IteratorT>(it_begin)),
491 end_(std::forward<IteratorT>(it_end)) {}
492
493 IteratorT begin() const { return begin_; }
494 IteratorT end() const { return end_; }
495 bool empty() const { return begin_ == end_; }
496
497 typename IteratorT::value_type at(typename IteratorT::difference_type pos) const {
498 static_assert(IsRandomAccess, "at() needs random access iterator");
499 auto it = begin_;
500 std::advance(it, pos);
501 return *it;
502 }
503
504 typename IteratorT::value_type operator[](typename IteratorT::difference_type pos) const {
505 return at(pos);
506 }
507
508 std::ptrdiff_t size() const {
509 static_assert(IsRandomAccess, "size() needs random access iterator");
510 return std::distance(begin_, end_);
511 }
512
513 protected:
514 enum {
515 IsRandomAccess = std::is_base_of<std::random_access_iterator_tag,
516 typename IteratorT::iterator_category>::value,
517 IsBidirectional = std::is_base_of<std::bidirectional_iterator_tag,
518 typename IteratorT::iterator_category>::value,
519 };
520 private:
521 IteratorT begin_;
522 IteratorT end_;
523};
524
525template <class T> iterator_range<T> make_range(T&& x, T&& y) {
526 return iterator_range<T>(std::forward<T>(x), std::forward<T>(y));
527}
528
529template <typename DerivedT, typename IteratorCategoryT, typename T,
588 typename DifferenceTypeT = std::ptrdiff_t, typename PointerT = T *,
589 typename ReferenceT = T &>
591public:
592 using iterator_category = IteratorCategoryT;
593 using value_type = T;
594 using difference_type = DifferenceTypeT;
595 using pointer = PointerT;
596 using reference = ReferenceT;
597
598protected:
599 enum {
600 IsRandomAccess = std::is_base_of<std::random_access_iterator_tag,
601 IteratorCategoryT>::value,
602 IsBidirectional = std::is_base_of<std::bidirectional_iterator_tag,
603 IteratorCategoryT>::value,
604 };
605 class ReferenceProxy {
612 friend iterator_facade_base;
613
614 DerivedT I;
615
616 ReferenceProxy(DerivedT I) : I(std::move(I)) {}
617
618 public:
619 operator ReferenceT() const { return *I; }
620 };
621 class PointerProxy {
627 friend iterator_facade_base;
628
629 ReferenceT R;
630
631 template <typename RefT>
632 PointerProxy(RefT &&R) : R(std::forward<RefT>(R)) {}
633
634 public:
635 PointerT operator->() const { return &R; }
636 };
637
638public:
639 DerivedT operator+(DifferenceTypeT n) const {
640 static_assert(std::is_base_of<iterator_facade_base, DerivedT>::value,
641 "Must pass the derived type to this template!");
642 static_assert(
643 IsRandomAccess,
644 "The '+' operator is only defined for random access iterators.");
645 DerivedT tmp = *static_cast<const DerivedT *>(this);
646 tmp += n;
647 return tmp;
648 }
649 friend DerivedT operator+(DifferenceTypeT n, const DerivedT &i) {
650 static_assert(
651 IsRandomAccess,
652 "The '+' operator is only defined for random access iterators.");
653 return i + n;
654 }
655 DerivedT operator-(DifferenceTypeT n) const {
656 static_assert(
657 IsRandomAccess,
658 "The '-' operator is only defined for random access iterators.");
659 DerivedT tmp = *static_cast<const DerivedT *>(this);
660 tmp -= n;
661 return tmp;
662 }
663
664 DerivedT &operator++() {
665 static_assert(std::is_base_of<iterator_facade_base, DerivedT>::value,
666 "Must pass the derived type to this template!");
667 return static_cast<DerivedT *>(this)->operator+=(1);
668 }
669 DerivedT operator++(int) {
670 DerivedT tmp = *static_cast<DerivedT *>(this);
671 ++*static_cast<DerivedT *>(this);
672 return tmp;
673 }
674 DerivedT &operator--() {
675 static_assert(
676 IsBidirectional,
677 "The decrement operator is only defined for bidirectional iterators.");
678 return static_cast<DerivedT *>(this)->operator-=(1);
679 }
680 DerivedT operator--(int) {
681 static_assert(
682 IsBidirectional,
683 "The decrement operator is only defined for bidirectional iterators.");
684 DerivedT tmp = *static_cast<DerivedT *>(this);
685 --*static_cast<DerivedT *>(this);
686 return tmp;
687 }
688
689#ifndef __cpp_impl_three_way_comparison
690 bool operator!=(const DerivedT &RHS) const {
691 return !(static_cast<const DerivedT &>(*this) == RHS);
692 }
693#endif
694
695 bool operator>(const DerivedT &RHS) const {
696 static_assert(
697 IsRandomAccess,
698 "Relational operators are only defined for random access iterators.");
699 return !(static_cast<const DerivedT &>(*this) < RHS) &&
700 !(static_cast<const DerivedT &>(*this) == RHS);
701 }
702 bool operator<=(const DerivedT &RHS) const {
703 static_assert(
704 IsRandomAccess,
705 "Relational operators are only defined for random access iterators.");
706 return !(static_cast<const DerivedT &>(*this) > RHS);
707 }
708 bool operator>=(const DerivedT &RHS) const {
709 static_assert(
710 IsRandomAccess,
711 "Relational operators are only defined for random access iterators.");
712 return !(static_cast<const DerivedT &>(*this) < RHS);
713 }
714
715 PointerProxy operator->() const {
716 return static_cast<const DerivedT *>(this)->operator*();
717 }
718 ReferenceProxy operator[](DifferenceTypeT n) const {
719 static_assert(IsRandomAccess,
720 "Subscripting is only defined for random access iterators.");
721 return static_cast<const DerivedT *>(this)->operator+(n);
722 }
723};
724template <
731 typename DerivedT, typename WrappedIteratorT,
732 typename IteratorCategoryT =
733 typename std::iterator_traits<WrappedIteratorT>::iterator_category,
734 typename T = typename std::iterator_traits<WrappedIteratorT>::value_type,
735 typename DifferenceTypeT =
736 typename std::iterator_traits<WrappedIteratorT>::difference_type,
737 typename PointerT = typename std::conditional<
738 std::is_same<T, typename std::iterator_traits<
739 WrappedIteratorT>::value_type>::value,
740 typename std::iterator_traits<WrappedIteratorT>::pointer, T *>,
741 typename ReferenceT = typename std::conditional<
742 std::is_same<T, typename std::iterator_traits<
743 WrappedIteratorT>::value_type>::value,
744 typename std::iterator_traits<WrappedIteratorT>::reference, T &>::type>
746 : public iterator_facade_base<DerivedT, IteratorCategoryT, T,
747 DifferenceTypeT, PointerT, ReferenceT> {
748 using BaseT = typename iterator_adaptor_base::iterator_facade_base;
749
750protected:
751 WrappedIteratorT I;
752
753 iterator_adaptor_base() = default;
754
755 explicit iterator_adaptor_base(WrappedIteratorT u) : I(std::move(u)) {
756 static_assert(std::is_base_of<iterator_adaptor_base, DerivedT>::value,
757 "Must pass the derived type to this template!");
758 }
759
760 const WrappedIteratorT &wrapped() const { return I; }
761
762public:
763 using difference_type = DifferenceTypeT;
764
766 static_assert(
767 BaseT::IsRandomAccess,
768 "The '+=' operator is only defined for random access iterators.");
769 I += n;
770 return *static_cast<DerivedT *>(this);
771 }
773 static_assert(
774 BaseT::IsRandomAccess,
775 "The '-=' operator is only defined for random access iterators.");
776 I -= n;
777 return *static_cast<DerivedT *>(this);
778 }
779 using BaseT::operator-;
780 difference_type operator-(const DerivedT &RHS) const {
781 static_assert(
782 BaseT::IsRandomAccess,
783 "The '-' operator is only defined for random access iterators.");
784 return I - RHS.I;
785 }
786
787 // We have to explicitly provide ++ and -- rather than letting the facade
788 // forward to += because WrappedIteratorT might not support +=.
789 using BaseT::operator++;
790 DerivedT &operator++() {
791 ++I;
792 return *static_cast<DerivedT *>(this);
793 }
794 using BaseT::operator--;
795 DerivedT &operator--() {
796 static_assert(
797 BaseT::IsBidirectional,
798 "The decrement operator is only defined for bidirectional iterators.");
799 --I;
800 return *static_cast<DerivedT *>(this);
801 }
802
803 friend bool operator==(const iterator_adaptor_base &LHS,
804 const iterator_adaptor_base &RHS) {
805 return LHS.I == RHS.I;
806 }
807 friend bool operator<(const iterator_adaptor_base &LHS,
808 const iterator_adaptor_base &RHS) {
809 static_assert(
810 BaseT::IsRandomAccess,
811 "Relational operators are only defined for random access iterators.");
812 return LHS.I < RHS.I;
813 }
814
815 ReferenceT operator*() const { return *I; }
816};
817template <typename WrappedIteratorT,
828 typename T = typename std::remove_reference<decltype(
829 **std::declval<WrappedIteratorT>())>::type>
832 pointee_iterator<WrappedIteratorT, T>, WrappedIteratorT,
833 typename std::iterator_traits<WrappedIteratorT>::iterator_category,
834 T> {
835 pointee_iterator() = default;
836 template <typename U>
838 : pointee_iterator::iterator_adaptor_base(std::forward<U &&>(u)) {}
839
840 T &operator*() const { return **this->I; }
841};
842
843template <typename RangeT, typename WrappedIteratorT =
844 decltype(std::begin(std::declval<RangeT>()))>
846make_pointee_range(RangeT &&Range) {
847 using PointeeIteratorT = pointee_iterator<WrappedIteratorT>;
848 return make_range(PointeeIteratorT(std::begin(std::forward<RangeT>(Range))),
849 PointeeIteratorT(std::end(std::forward<RangeT>(Range))));
850}
851
852template <typename WrappedIteratorT,
853 typename T = decltype(&*std::declval<WrappedIteratorT>())>
855 : public iterator_adaptor_base<
856 pointer_iterator<WrappedIteratorT, T>, WrappedIteratorT,
857 typename std::iterator_traits<WrappedIteratorT>::iterator_category,
858 T> {
859 mutable T Ptr;
860
861public:
862 pointer_iterator() = default;
863
864 explicit pointer_iterator(WrappedIteratorT u)
865 : pointer_iterator::iterator_adaptor_base(std::move(u)) {}
866
867 T &operator*() const { return Ptr = &*this->I; }
868};
869
870template <typename RangeT, typename WrappedIteratorT =
871 decltype(std::begin(std::declval<RangeT>()))>
873make_pointer_range(RangeT &&Range) {
874 using PointerIteratorT = pointer_iterator<WrappedIteratorT>;
875 return make_range(PointerIteratorT(std::begin(std::forward<RangeT>(Range))),
876 PointerIteratorT(std::end(std::forward<RangeT>(Range))));
877}
878
879template <typename WrappedIteratorT,
880 typename T1 = typename std::remove_reference<decltype(
881 **std::declval<WrappedIteratorT>())>::type,
882 typename T2 = typename std::add_pointer<T1>::type>
885
886}
887
888#endif
Iterator which return a ref on container's values given predicates.
Definition iterators.hpp:263
std::enable_if<!std::is_pointer< V >::value, add_const_t< ref_t > >::type operator*() const
Definition iterators.hpp:393
bool operator==(const filter_iterator &other) const
Definition iterators.hpp:444
filter_iterator(const filter_iterator &copy)
Definition iterators.hpp:317
add_const_t< ref_t > operator[](size_t n) const
Definition iterators.hpp:403
filter_iterator cend() const
Definition iterators.hpp:375
typename std::remove_pointer< U >::type * pointer
Definition iterators.hpp:269
filter_iterator(T container, filter_t filter)
Definition iterators.hpp:279
std::forward_iterator_tag iterator_category
Definition iterators.hpp:266
filter_iterator(T container)
Definition iterators.hpp:310
void swap(filter_iterator &other) noexcept
Definition iterators.hpp:331
filter_iterator & operator++()
Definition iterators.hpp:346
std::enable_if<!std::is_const< pointer_t >::value, pointer_t >::type operator->()
Definition iterators.hpp:413
filter_iterator(T container, const std::vector< filter_t > &filters)
Definition iterators.hpp:296
filter_iterator end() const
Definition iterators.hpp:365
typename filter_iterator::pointer pointer_t
Definition iterators.hpp:276
filter_iterator & operator=(filter_iterator other)
Definition iterators.hpp:326
decay_t< U > value_type
Definition iterators.hpp:267
typename filter_iterator::reference ref_t
Definition iterators.hpp:275
std::enable_if<!std::is_const< ref_t >::value, remove_const_t< ref_t > >::type operator*()
Definition iterators.hpp:380
filter_iterator begin() const
Definition iterators.hpp:357
bool empty() const
Definition iterators.hpp:439
U DT_VAL
Definition iterators.hpp:273
ptrdiff_t difference_type
Definition iterators.hpp:268
add_const_t< pointer_t > operator->() const
Definition iterators.hpp:417
std::function< bool(const typename DT::value_type &)> filter_t
Definition iterators.hpp:277
size_t size() const
Definition iterators.hpp:421
std::enable_if< std::is_pointer< V >::value, add_const_t< ref_t > >::type operator*() const
Definition iterators.hpp:386
bool operator!=(const filter_iterator &other) const
Definition iterators.hpp:448
T container_type
Definition iterators.hpp:272
filter_iterator operator++(int)
Definition iterators.hpp:351
decay_t< T > DT
Definition iterators.hpp:274
filter_iterator cbegin() const
Definition iterators.hpp:361
filter_iterator & def(filter_t func)
Definition iterators.hpp:340
typename std::remove_pointer< U >::type & reference
Definition iterators.hpp:270
std::enable_if<!std::is_const< ref_t >::value, remove_const_t< ref_t > >::type operator[](size_t n)
Definition iterators.hpp:399
CRTP base class for adapting an iterator to a different type.
Definition iterators.hpp:747
DerivedT & operator++()
Definition iterators.hpp:790
DerivedT & operator--()
Definition iterators.hpp:795
DerivedT & operator-=(difference_type n)
Definition iterators.hpp:772
ReferenceT operator*() const
Definition iterators.hpp:815
friend bool operator<(const iterator_adaptor_base &LHS, const iterator_adaptor_base &RHS)
Definition iterators.hpp:807
friend bool operator==(const iterator_adaptor_base &LHS, const iterator_adaptor_base &RHS)
Definition iterators.hpp:803
DifferenceTypeT difference_type
Definition iterators.hpp:763
DerivedT & operator+=(difference_type n)
Definition iterators.hpp:765
difference_type operator-(const DerivedT &RHS) const
Definition iterators.hpp:780
CRTP base class which implements the entire standard iterator facade in terms of a minimal subset of ...
Definition iterators.hpp:590
DifferenceTypeT difference_type
Definition iterators.hpp:594
PointerProxy operator->() const
Definition iterators.hpp:715
DerivedT & operator--()
Definition iterators.hpp:674
DerivedT operator++(int)
Definition iterators.hpp:669
T value_type
Definition iterators.hpp:593
friend DerivedT operator+(DifferenceTypeT n, const DerivedT &i)
Definition iterators.hpp:649
bool operator>(const DerivedT &RHS) const
Definition iterators.hpp:695
ReferenceProxy operator[](DifferenceTypeT n) const
Definition iterators.hpp:718
ReferenceT reference
Definition iterators.hpp:596
bool operator>=(const DerivedT &RHS) const
Definition iterators.hpp:708
DerivedT operator-(DifferenceTypeT n) const
Definition iterators.hpp:655
DerivedT & operator++()
Definition iterators.hpp:664
PointerT pointer
Definition iterators.hpp:595
DerivedT operator--(int)
Definition iterators.hpp:680
IteratorCategoryT iterator_category
Definition iterators.hpp:592
DerivedT operator+(DifferenceTypeT n) const
Definition iterators.hpp:639
bool operator!=(const DerivedT &RHS) const
Definition iterators.hpp:690
bool operator<=(const DerivedT &RHS) const
Definition iterators.hpp:702
Definition iterators.hpp:486
IteratorT begin() const
Definition iterators.hpp:493
IteratorT end() const
Definition iterators.hpp:494
IteratorT::value_type operator[](typename IteratorT::difference_type pos) const
Definition iterators.hpp:504
bool empty() const
Definition iterators.hpp:495
IteratorT::value_type at(typename IteratorT::difference_type pos) const
Definition iterators.hpp:497
iterator_range(IteratorT &&it_begin, IteratorT &&it_end)
Definition iterators.hpp:489
IteratorT IteratorTy
Definition iterators.hpp:488
std::ptrdiff_t size() const
Definition iterators.hpp:508
Definition iterators.hpp:858
T & operator*() const
Definition iterators.hpp:867
pointer_iterator(WrappedIteratorT u)
Definition iterators.hpp:864
Iterator which returns reference on container's values.
Definition iterators.hpp:46
bool operator<=(const ref_iterator &rhs) const
Definition iterators.hpp:181
ref_iterator & operator--()
Definition iterators.hpp:100
size_t size() const
Definition iterators.hpp:212
ref_iterator & operator++()
Definition iterators.hpp:88
void swap(ref_iterator &other) noexcept
Definition iterators.hpp:80
bool operator<(const ref_iterator &rhs) const
Definition iterators.hpp:166
ref_iterator operator-(typename ref_iterator::difference_type n) const
Definition iterators.hpp:156
ref_iterator operator++(int)
Definition iterators.hpp:94
ref_iterator begin() const
Definition iterators.hpp:185
T container_type
Definition iterators.hpp:54
typename ref_iterator::reference ref_t
Definition iterators.hpp:57
ref_iterator operator--(int)
Definition iterators.hpp:108
ref_iterator cend() const
Definition iterators.hpp:200
ref_iterator & operator+=(const typename ref_iterator::difference_type &movement)
Definition iterators.hpp:115
std::bidirectional_iterator_tag iterator_category
Definition iterators.hpp:48
ptrdiff_t difference_type
Definition iterators.hpp:50
ref_iterator operator+(typename ref_iterator::difference_type n) const
Definition iterators.hpp:150
typename std::remove_pointer< U >::type & reference
Definition iterators.hpp:52
ref_iterator cbegin() const
Definition iterators.hpp:189
bool empty() const
Definition iterators.hpp:216
ref_iterator & operator=(ref_iterator other)
Definition iterators.hpp:75
typename std::remove_pointer< U >::type * pointer
Definition iterators.hpp:51
bool operator!=(const ref_iterator &other) const
Definition iterators.hpp:208
std::enable_if<!std::is_const< ref_t >::value, remove_const_t< ref_t > >::type operator[](size_t n)
Definition iterators.hpp:128
bool operator>(const ref_iterator &rhs) const
Definition iterators.hpp:171
bool operator>=(const ref_iterator &rhs) const
Definition iterators.hpp:176
ref_iterator(const ref_iterator &copy)
Definition iterators.hpp:66
ref_iterator end() const
Definition iterators.hpp:193
std::enable_if< std::is_pointer< V >::value, add_const_t< ref_t > >::type operator*() const
Definition iterators.hpp:227
std::enable_if<!std::is_pointer< V >::value, add_const_t< ref_t > >::type operator*() const
Definition iterators.hpp:234
ref_iterator & operator-=(const typename ref_iterator::difference_type &movement)
Definition iterators.hpp:122
add_const_t< ref_t > operator[](size_t n) const
Definition iterators.hpp:133
decay_t< U > value_type
Definition iterators.hpp:49
std::enable_if<!std::is_const< ref_t >::value, remove_const_t< ref_t > >::type operator*()
Definition iterators.hpp:221
ref_iterator::difference_type operator-(const ref_iterator &rhs) const
Definition iterators.hpp:162
U DT_VAL
Definition iterators.hpp:55
typename ref_iterator::pointer pointer_t
Definition iterators.hpp:58
ref_iterator(T container)
Definition iterators.hpp:60
std::enable_if<!std::is_const< pointer_t >::value, pointer_t >::type operator->()
Definition iterators.hpp:240
add_const_t< pointer_t > operator->() const
Definition iterators.hpp:244
bool operator==(const ref_iterator &other) const
Definition iterators.hpp:204
decay_t< T > DT
Definition iterators.hpp:56
LIEF namespace.
Definition Abstract/Binary.hpp:36
filter_iterator< CT, U, typename decay_t< CT >::const_iterator > const_filter_iterator
Iterator which return a const ref on container's values given predicates.
Definition iterators.hpp:479
typename std::add_lvalue_reference< T >::type add_lvalue_reference_t
Definition iterators.hpp:40
typename std::remove_const< T >::type remove_const_t
Definition iterators.hpp:37
pointer_iterator< pointee_iterator< WrappedIteratorT, T1 >, T2 > raw_pointer_iterator
Definition iterators.hpp:883
typename std::decay< T >::type decay_t
Definition iterators.hpp:31
iterator_range< pointee_iterator< WrappedIteratorT > > make_pointee_range(RangeT &&Range)
Definition iterators.hpp:846
iterator_range< T > make_range(T &&x, T &&y)
Definition iterators.hpp:525
iterator_range< pointer_iterator< WrappedIteratorT > > make_pointer_range(RangeT &&Range)
Definition iterators.hpp:873
ref_iterator< CT, U, typename decay_t< CT >::const_iterator > const_ref_iterator
Iterator which return const ref on container's values.
Definition iterators.hpp:257
typename std::add_const< T >::type add_const_t
Definition iterators.hpp:34
An iterator type that allows iterating over the pointees via some other iterator.
Definition iterators.hpp:834
T & operator*() const
Definition iterators.hpp:840
pointee_iterator(U &&u)
Definition iterators.hpp:837