Go to the documentation of this file.
14 #ifndef CPROVER_UTIL_RANGE_H
15 #define CPROVER_UTIL_RANGE_H
18 #include <type_traits>
25 template <
typename iteratort,
typename outputt>
87 std::function<
value_type(
const typename iteratort::value_type &)>>
f)
92 if(this->underlying != this->underlying_end)
93 current = std::make_shared<outputt>((*this->
f)(*this->underlying));
100 std::function<
value_type(
const typename iteratort::value_type &)>>
110 template <
typename iteratort>
153 return &(*underlying);
163 return &(*underlying);
174 std::shared_ptr<std::function<
bool(
const value_type &)>>
f,
205 template <
typename first_iteratort,
typename second_iteratort>
216 std::is_same<value_type, typename first_iteratort::value_type>::value,
217 "Concatenated iterators should have the same value type");
227 return !(*
this == other);
258 return &(*second_begin);
259 return &(*first_begin);
272 return &(*second_begin);
273 return &(*first_begin);
310 template <
typename iteratort>
323 auto shared_f = std::make_shared<decltype(f)>(std::move(f));
335 template <
typename functiont>
338 typename std::result_of<functiont(
value_typet)>::type>>
340 using outputt =
typename std::result_of<functiont(
value_typet)>::type;
341 auto shared_f = std::make_shared<
342 std::function<outputt(
const typename iteratort::value_type &)>>(
343 std::forward<functiont>(f));
348 std::move(map_begin), std::move(map_end));
351 template <
typename other_iteratort>
360 concat_begin, concat_end);
373 const iteratort &
end()
const
383 template <
typename iteratort>
389 template <
typename containert>
392 return ranget<decltype(container.begin())>(
393 container.begin(), container.end());
396 #endif // CPROVER_UTIL_RANGE_H
typename first_iteratort::value_type value_type
const iteratort underlying_end
bool operator==(const map_iteratort &other) const
#define PRECONDITION(CONDITION)
value_type * operator->()
concat_iteratort & operator++()
Preincrement operator.
void point_to_first_to_peek()
Ensure that the underlying iterator is always positioned on an element for which f is true.
map_iteratort & operator++()
Preincrement operator.
const value_type * operator->() const
first_iteratort first_end
const iteratort & end() const
bool operator==(const concat_iteratort &other) const
std::forward_iterator_tag iterator_category
typename iteratort::value_type value_typet
const value_type & operator*() const
value_type * operator->()
Iterator which applies some given function f after each increment and returns its result on dereferen...
auto map(functiont &&f) -> ranget< map_iteratort< iteratort, typename std::result_of< functiont(value_typet)>::type >>
The type of elements contained in the resulting range is deduced from the return type of f.
const value_type * pointer
On increment, increments a first iterator and when the corresponding end iterator is reached,...
std::forward_iterator_tag iterator_category
const value_type * operator->() const
typename iteratort::difference_type difference_type
A range is a pair of a begin and an end iterators.
second_iteratort second_begin
filter_iteratort(std::shared_ptr< std::function< bool(const value_type &)>> f, iteratort underlying, iteratort end)
Filter between underlying and end using f.
std::shared_ptr< outputt > current
Stores the result of f at the current position of the iterator.
typename iteratort::difference_type difference_type
Iterator which only stops at elements for which some given function f is true.
bool operator!=(const map_iteratort &other) const
const value_type * pointer
typename iteratort::value_type value_type
ranget< filter_iteratort< iteratort > > filter(std::function< bool(const value_typet &)> f)
ranget(iteratort begin, iteratort end)
const value_type & reference
map_iteratort(iteratort underlying, iteratort underlying_end, std::shared_ptr< std::function< value_type(const typename iteratort::value_type &)>> f)
bool operator!=(const concat_iteratort &other) const
const outputt & reference
const filter_iteratort operator++(int)
Postincrement operator.
std::forward_iterator_tag iterator_category
first_iteratort first_begin
const value_type & operator*() const
concat_iteratort(first_iteratort first_begin, first_iteratort first_end, second_iteratort second_begin)
bool operator==(const filter_iteratort &other) const
std::shared_ptr< std::function< value_type(const typename iteratort::value_type &)> > f
const concat_iteratort operator++(int)
Postincrement operator.
filter_iteratort & operator++()
Preincrement operator.
value_type * operator->()
const map_iteratort operator++(int)
Postincrement operator.
const value_type * operator->() const
typename first_iteratort::difference_type difference_type
const value_type & operator*() const
bool operator!=(const filter_iteratort &other) const
const value_type & reference
ranget< iteratort > make_range(iteratort begin, iteratort end)
std::shared_ptr< std::function< bool(const value_type &)> > f
ranget< concat_iteratort< iteratort, other_iteratort > > concat(ranget< other_iteratort > other)