SPH
OutputIterators.h
Go to the documentation of this file.
1 #pragma once
2 
7 
8 #include "common/Assert.h"
9 
11 
13 class NullInserter {
14 public:
16  return *this;
17  }
18 
20  return *this;
21  }
22 
23  template <typename TValue>
24  NullInserter& operator=(TValue&&) {
25  return *this;
26  }
27 
28  using iterator_category = std::output_iterator_tag;
29  using value_type = void;
30  using difference_type = ptrdiff_t;
31  using pointer = void;
32  using reference = void;
33 };
34 
36 template <typename TContainer>
37 class BackInserter {
38 private:
39  TContainer& container;
40 
41 public:
42  explicit BackInserter(TContainer& container)
43  : container(container) {}
44 
46  return *this;
47  }
48 
50  return *this;
51  }
52 
53  template <typename TValue>
54  BackInserter& operator=(TValue&& value) {
55  container.push(std::forward<TValue>(value));
56  return *this;
57  }
58 
59  using iterator_category = std::output_iterator_tag;
60  using value_type = void;
61  using difference_type = ptrdiff_t;
62  using pointer = void;
63  using reference = void;
64 };
65 
66 template <typename TContainer>
68  return BackInserter<TContainer>(c);
69 }
70 
Custom assertions.
NAMESPACE_SPH_BEGIN
Definition: BarnesHut.cpp:13
#define NAMESPACE_SPH_END
Definition: Object.h:12
BackInserter< TContainer > backInserter(TContainer &c)
Output iterator that inserts the written values to the given iterator using push function.
BackInserter & operator++()
BackInserter & operator=(TValue &&value)
BackInserter & operator*()
BackInserter(TContainer &container)
std::output_iterator_tag iterator_category
ptrdiff_t difference_type
Helper output iterator that simply ignores the written values.
NullInserter & operator=(TValue &&)
NullInserter & operator*()
NullInserter & operator++()
ptrdiff_t difference_type
std::output_iterator_tag iterator_category