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 bool operator==(const concat_iteratort &other) const
bool operator!=(const filter_iteratort &other) const
bool operator!=(const concat_iteratort &other) const
first_iteratort first_begin
const value_type * operator->() const
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.
void point_to_first_to_peek()
Ensure that the underlying iterator is always positioned on an element for which f is true.
Iterator which applies some given function f after each increment and returns its result on dereferen...
const value_type & reference
std::forward_iterator_tag iterator_category
typename first_iteratort::value_type value_type
std::shared_ptr< outputt > current
Stores the result of f at the current position of the iterator.
std::shared_ptr< std::function< bool(const value_type &)> > f
ranget(iteratort begin, iteratort end)
typename iteratort::difference_type difference_type
value_type * operator->()
Iterator which only stops at elements for which some given function f is true.
const value_type * pointer
second_iteratort second_begin
const value_type * operator->() const
value_type & operator *()
value_type * operator->()
ranget< filter_iteratort< iteratort > > filter(std::function< bool(const value_typet &)> f)
bool operator!=(const map_iteratort &other) const
filter_iteratort(std::shared_ptr< std::function< bool(const value_type &)>> f, iteratort underlying, iteratort end)
Filter between underlying and end using f.
map_iteratort & operator++()
Preincrement operator.
const outputt & reference
std::shared_ptr< std::function< value_type(const typename iteratort::value_type &)> > f
#define PRECONDITION(CONDITION)
const value_type & reference
value_type & operator *()
ranget< iteratort > make_range(iteratort begin, iteratort end)
std::forward_iterator_tag iterator_category
std::forward_iterator_tag iterator_category
map_iteratort(iteratort underlying, iteratort underlying_end, std::shared_ptr< std::function< value_type(const typename iteratort::value_type &)>> f)
typename first_iteratort::difference_type difference_type
concat_iteratort(first_iteratort first_begin, first_iteratort first_end, second_iteratort second_begin)
value_type & operator *()
bool operator==(const filter_iteratort &other) const
typename iteratort::difference_type difference_type
typename iteratort::value_type value_typet
value_type * operator->()
typename iteratort::value_type value_type
const value_type * operator->() const
const iteratort & end() const
const filter_iteratort operator++(int)
Postincrement operator.
const value_type * pointer
concat_iteratort & operator++()
Preincrement operator.
first_iteratort first_end
A range is a pair of a begin and an end iterators.
const iteratort underlying_end
On increment, increments a first iterator and when the corresponding end iterator is reached,...
ranget< concat_iteratort< iteratort, other_iteratort > > concat(ranget< other_iteratort > other)
const map_iteratort operator++(int)
Postincrement operator.
const concat_iteratort operator++(int)
Postincrement operator.
bool operator==(const map_iteratort &other) const
filter_iteratort & operator++()
Preincrement operator.