|
| ranget (iteratort begin, iteratort end) |
|
ranget< filter_iteratort< iteratort > > | filter (std::function< bool(const value_type &)> f) |
|
template<typename functiont > |
auto | map (functiont &&f) |
| The type of elements contained in the resulting range is deduced from the return type of f . More...
|
|
template<typename other_iteratort > |
ranget< concat_iteratort< iteratort, other_iteratort > > | concat (ranget< other_iteratort > other) |
|
template<bool same_size = true, typename other_iteratort > |
ranget< zip_iteratort< iteratort, other_iteratort, same_size > > | zip (ranget< other_iteratort > other) |
| Combine two ranges to make a range over pairs. More...
|
|
template<bool same_size = true, typename containert > |
auto | zip (containert &container) -> ranget< zip_iteratort< iteratort, decltype(container.begin()), same_size >> |
|
bool | empty () const |
|
ranget< iteratort > | drop (std::size_t count) && |
| Return an new range containing the same elements except for the first count elements. More...
|
|
ranget< iteratort > | drop (std::size_t count) const & |
| Return an new range containing the same elements except for the first count elements. More...
|
|
iteratort | begin () const |
|
const iteratort & | end () const |
|
template<typename containert > |
containert | collect () const |
| Constructs a collection containing the values, which this range iterates over. More...
|
|
template<typename containert > |
| operator containert () const |
|
template<typename iteratort>
struct ranget< iteratort >
A range is a pair of a begin and an end iterators.
The class provides useful methods such as map, filter and concat which only manipulate iterators and thus don't have to create instances of heavy data structures and avoid copies. For instance, to iterate over two vectors, instead of writing
std::vector new_vector;
std::copy(v1.begin(), v1.end(), std::back_inserter(new_vector));
std::copy(v2.begin(), v2.end(), std::back_inserter(new_vector));
for(const auto &a : new_vector) {...}
It is possible to write:
auto range = make_range(v1).concat(make_range(v2));
for(const auto &a : range) {...}
Which is clearer and has the advantage of avoiding the creation of the intermediary vector and the potentially expensive copies.
Definition at line 395 of file range.h.
template<typename iteratort >
template<typename functiont >
The type of elements contained in the resulting range is deduced from the return type of f
.
Please note that the parameter to f
must be a const reference. This is a limitation of the current implementation. This means that you can't move a value through f
. f
may take a move-only typed parameter by const reference. 'f' may also construct and return a move-only typed value.
Definition at line 421 of file range.h.