memgraph/include/utils/iterator/for_all.hpp
Kruno Tomola Fabro 77a3298d1e tmp
2016-08-28 15:47:13 +01:00

29 lines
467 B
C++

#pragma once
#include <memory>
#include "utils/option.hpp"
namespace iter
{
template <class I, class C>
void for_all(I &&iter, C &&consumer)
{
auto e = iter.next();
while (e.is_present()) {
consumer(e.take());
e = iter.next();
}
}
template <class I, class C>
void for_all(std::unique_ptr<I> &&iter, C &&consumer)
{
auto e = iter->next();
while (e.is_present()) {
consumer(e.take());
e = iter->next();
}
}
}