Graphle 1.0.0
A C++20 header-only graph library
Loading...
Searching...
No Matches
vec_of_vecs_output_iterator.hpp
Go to the documentation of this file.
1#pragma once
2
3#include <common.hpp>
6
7#include <concepts>
8#include <vector>
9
10
11namespace graphle::util {
16 template <
17 typename VV,
18 store::storage_provider_ref<store::storage_type::VECTOR, typename VV::value_type> PV
20 public:
21 using value_type = typename std::back_insert_iterator<VV>;
24 using difference_type = std::ptrdiff_t;
25 using iterator_category = std::output_iterator_tag;
26
27
28 explicit vec_of_vecs_output_iterator(VV& target, PV& provider) :
29 target(std::addressof(target)),
30 provider(std::addressof(provider))
31 {}
32
33
34 value_type operator*(void) const {
35 return std::back_inserter(target->back());
36 }
37
38
40 target->emplace_back((*provider)());
41 return *this;
42 }
43
44
46 auto old = *this;
47 target->emplace_back((*provider)());
48 return old;
49 }
50 private:
51 VV* target;
52 PV* provider;
53 };
54}
typename std::back_insert_iterator< VV > value_type
constexpr addressof_t addressof
Definition: functional.hpp:61