Support Class Library
A set of tools providing classes and utility
toSet.h
Go to the documentation of this file.
1 #pragma once
3 #include <set>
4 #include <scl/stream/Stream.h>
6 
7 namespace scl {
8  namespace stream {
9  namespace terminators {
10  namespace pack {
11  namespace details {
18  template <class T, class Compare = std::less<T>, class Allocator = std::allocator<T>>
19  class SetPacker : public scl::stream::details::iterator::EndStreamIterator<std::set<T, Compare, Allocator>, T>{
20  public:
27 
32  using compare_type = Compare;
33 
38  using allocator_type = Allocator;
39 
40  explicit SetPacker(parent_type p) : iterator_type{std::move(p)} {
41  }
42 
44  result_type ret;
45 
46  /*while(this->hasNext()){
47  auto alt = this->next().value();
48  if(alt.hasValue())
49  ret.insert(*alt);
50  }*/
51 
52  for(auto&& payload : *this){
53  if(payload.isValid())
54  ret.insert(*payload.value());
55  }
56 
57  return ret;
58  }
59  };
60 
64  struct to_set_toolbox{};
65 
71  template <class Compare, class Allocator>
73  }
74 
80 
87  template <class Compare, class Allocator>
89  }
90 
98  template <class T>
100  auto packer = pack::details::SetPacker<T>{lhs.it()};
101  return packer.process();
102  }
103 
113  template <class T, class Compare, class Allocator>
115  auto packer = pack::details::SetPacker<T>{lhs.it()};
116  return packer.process();
117  }
118  }
119  }
120 }
BaseStreamIterator< T > parent_iterator_type
Type alias for the "parent" iterator.
typename payload_type::value_type value_type
Type alias for the data type manipulated.
Compare compare_type
The type of comparator.
Definition: toSet.h:32
Global namespace of the SCL.
Definition: alias.hpp:3
void operator|(const Stream< T > &lhs, const details::for_each_toolbox< T > &rhs)
Pipe operator overload for forEach terminators.
Definition: forEach.h:116
it_t it() const
Get a reference to the underlying iterator.
Definition: Stream.h:48
Tag type to pack into a std::set w/ default template parameters.
Definition: toSet.h:64
Class that allows packing to a std::set.
Definition: toSet.h:19
details::to_set_toolbox toSet()
Terminator for packing into a set.
Definition: toSet.h:79
Allocator allocator_type
The type of allocator.
Definition: toSet.h:38
constexpr scl::utils::Placeholder _
Definition: Placeholder.h:39
typename iterator_type::payload_type payload_type
Type alias for the payload used.
A class for iterators used in end operations.
typename iterator_type::parent_iterator_type parent_iterator_type
Definition: toSet.h:25
A class representing a stream iterator&#39;s payload.
Definition: payload.h:16
result_type process()
Process the return value.
Definition: toSet.h:43
Class representing a stream of data.
Definition: Stream.h:15
std::set< T, Compare, Allocator > result_type
Type alias for the computed result.
Tag type to pack into a std::set w/ control over template parameters.
Definition: toSet.h:72
typename iterator_type::parent_type parent_type
Definition: toSet.h:26
typename iterator_type::result_type result_type
Definition: toSet.h:24