EVMC
evmc::filter_iterator< BaseIterator, noexcept > Struct Template Reference

The filter iterator adaptor creates a view of an iterator range in which some elements of the range are skipped. More...

#include <filter_iterator.hpp>

Public Types

using difference_type = typename std::iterator_traits< BaseIterator >::difference_type
 The iterator difference type.
 
using value_type = typename std::iterator_traits< BaseIterator >::value_type
 The iterator value type.
 
using pointer = typename std::iterator_traits< BaseIterator >::pointer
 The iterator pointer type.
 
using reference = typename std::iterator_traits< BaseIterator >::reference
 The iterator reference type.
 
using iterator_category = std::input_iterator_tag
 The iterator category.
 

Public Member Functions

constexpr filter_iterator (BaseIterator it, BaseIterator end) noexcept
 The constructor of the base iterator pair.
 
constexpr auto operator* () noexcept
 The dereference operator.
 
constexpr void operator++ () noexcept
 The increment operator.
 
constexpr bool operator== (const filter_iterator &o) const noexcept
 The equality operator.
 
constexpr bool operator!= (const filter_iterator &o) const noexcept
 The inequality operator.
 

Detailed Description

template<typename BaseIterator, bool predicate(typename std::iterator_traits< BaseIterator >::value_type) noexcept>
struct evmc::filter_iterator< BaseIterator, noexcept >

The filter iterator adaptor creates a view of an iterator range in which some elements of the range are skipped.

A predicate function controls which elements are skipped. When the predicate is applied to an element, if it returns true then the element is retained and if it returns false then the element is skipped over. When skipping over elements, it is necessary for the filter adaptor to know when to stop so as to avoid going past the end of the underlying range. A filter iterator is therefore constructed with pair of iterators indicating the range of elements in the unfiltered sequence to be traversed.

Similar to boost::filter_iterator.

Definition at line 34 of file filter_iterator.hpp.

Member Typedef Documentation

◆ difference_type

template<typename BaseIterator , bool predicate(typename std::iterator_traits< BaseIterator >::value_type) noexcept>
using evmc::filter_iterator< BaseIterator, noexcept >::difference_type = typename std::iterator_traits<BaseIterator>::difference_type

The iterator difference type.

Definition at line 37 of file filter_iterator.hpp.

◆ iterator_category

template<typename BaseIterator , bool predicate(typename std::iterator_traits< BaseIterator >::value_type) noexcept>
using evmc::filter_iterator< BaseIterator, noexcept >::iterator_category = std::input_iterator_tag

The iterator category.

Definition at line 49 of file filter_iterator.hpp.

◆ pointer

template<typename BaseIterator , bool predicate(typename std::iterator_traits< BaseIterator >::value_type) noexcept>
using evmc::filter_iterator< BaseIterator, noexcept >::pointer = typename std::iterator_traits<BaseIterator>::pointer

The iterator pointer type.

Definition at line 43 of file filter_iterator.hpp.

◆ reference

template<typename BaseIterator , bool predicate(typename std::iterator_traits< BaseIterator >::value_type) noexcept>
using evmc::filter_iterator< BaseIterator, noexcept >::reference = typename std::iterator_traits<BaseIterator>::reference

The iterator reference type.

Definition at line 46 of file filter_iterator.hpp.

◆ value_type

template<typename BaseIterator , bool predicate(typename std::iterator_traits< BaseIterator >::value_type) noexcept>
using evmc::filter_iterator< BaseIterator, noexcept >::value_type = typename std::iterator_traits<BaseIterator>::value_type

The iterator value type.

Definition at line 40 of file filter_iterator.hpp.

Constructor & Destructor Documentation

◆ filter_iterator()

template<typename BaseIterator , bool predicate(typename std::iterator_traits< BaseIterator >::value_type) noexcept>
constexpr evmc::filter_iterator< BaseIterator, noexcept >::filter_iterator ( BaseIterator  it,
BaseIterator  end 
)
inlineconstexprnoexcept

The constructor of the base iterator pair.

Definition at line 68 of file filter_iterator.hpp.

68 : base{it}, base_end{end}
69 {
70 forward_to_next_value();
71 }

Member Function Documentation

◆ operator!=()

template<typename BaseIterator , bool predicate(typename std::iterator_traits< BaseIterator >::value_type) noexcept>
constexpr bool evmc::filter_iterator< BaseIterator, noexcept >::operator!= ( const filter_iterator< BaseIterator, noexcept > &  o) const
inlineconstexprnoexcept

The inequality operator.

Definition at line 92 of file filter_iterator.hpp.

92{ return base != o.base; }

◆ operator*()

template<typename BaseIterator , bool predicate(typename std::iterator_traits< BaseIterator >::value_type) noexcept>
constexpr auto evmc::filter_iterator< BaseIterator, noexcept >::operator* ( )
inlineconstexprnoexcept

The dereference operator.

Definition at line 74 of file filter_iterator.hpp.

75 {
76 // We should not read from an input base iterator twice. So the only read is in
77 // forward_to_next_value() and here we return the cached value.
78 return value;
79 }

◆ operator++()

template<typename BaseIterator , bool predicate(typename std::iterator_traits< BaseIterator >::value_type) noexcept>
constexpr void evmc::filter_iterator< BaseIterator, noexcept >::operator++ ( )
inlineconstexprnoexcept

The increment operator.

Definition at line 82 of file filter_iterator.hpp.

83 {
84 ++base;
85 forward_to_next_value();
86 }

◆ operator==()

template<typename BaseIterator , bool predicate(typename std::iterator_traits< BaseIterator >::value_type) noexcept>
constexpr bool evmc::filter_iterator< BaseIterator, noexcept >::operator== ( const filter_iterator< BaseIterator, noexcept > &  o) const
inlineconstexprnoexcept

The equality operator.

Definition at line 89 of file filter_iterator.hpp.

89{ return base == o.base; }

The documentation for this struct was generated from the following file: