7 #include <boost/range/algorithm/set_algorithm.hpp> 8 #include <boost/range/iterator_range_core.hpp> 15 template <
typename Range,
typename Predicate>
23 template <
typename Range>
29 [](
const auto& p) ->
bool {
return p; });
35 template <
typename Container>
36 typename Container::value_type
37 back(
const Container& container)
41 auto i = begin(container);
42 auto iend = end(container);
45 for (++i; i != iend; ++i)
54 template <
typename Container,
typename Predicate>
59 for (
auto i = begin(c); i != end(c); )
70 template <
typename Container>
71 typename Container::value_type
72 front(
const Container& container)
76 auto i = begin(container);
77 assert(i != end(container));
82 template <
typename Iterator,
typename Pred,
typename Less>
83 boost::iterator_range<Iterator>
88 for (
auto i = begin;; ++i)
90 auto next = std::next(i);
104 template <
typename Container,
typename Compare>
107 auto i = std::begin(container);
108 auto end = std::end(container);
112 for (++i; i != end; ++i)
127 template <
typename InputIt1,
typename InputIt2,
class Compare>
129 InputIt2 first2, InputIt2 last2,
132 for ( ; first1 != last1 && first2 != last2; ++first1, ++first2)
133 if (
auto res = comp(*first1, *first2))
138 return (first1 != last1) - (first2 != last2);
145 template <
typename Cont1,
typename Cont2,
typename Compare>
155 begin(cont2), end(cont2),
161 template <
typename Container>
162 typename Container::value_type
165 auto i = std::begin(container);
166 auto end = std::end(container);
169 for (++i; i != end; ++i)
177 template <
typename Container,
typename Comp>
178 typename Container::value_type
181 auto i = std::begin(container);
182 auto end = std::end(container);
185 for (++i; i != end; ++i)
192 template <
typename Range,
typename Predicate>
201 template <
typename Range,
typename Value>
204 return none_of(r, [&value](
const Value&
v) {
return v == value; });
210 template <
typename Container,
typename Fun>
213 using value_t = decltype(std::forward<Fun>(fun)(*begin(c)));
214 auto res = std::vector<value_t>(c.size());
221 template <
typename Container,
223 typename =
typename Container::value_type>
227 auto res = Container{s1.key_comp(), s1.get_allocator()};
228 auto i = std::insert_iterator<Container>{
res,
res.begin()};
234 template <
typename Container,
236 typename =
typename Container::value_type>
240 auto res = Container{s1.key_comp(), s1.get_allocator()};
241 auto i = std::insert_iterator<Container>{
res,
res.begin()};
247 template <
typename Container>
251 if (x.size() == y.size())
253 using std::begin;
using std::end;
254 for (
auto xi = begin(x), xend = end(x), yi = begin(y);
257 if (x.key_comp()(xi->first, yi->first)
258 || x.key_comp()(yi->first, xi->first))
267 template <
typename Container,
269 typename =
typename Container::value_type>
273 auto res = Container{s1.key_comp(), s1.get_allocator()};
274 auto i = std::insert_iterator<Container>{
res,
res.begin()};
bool any_of(const Range &r, Predicate p)
int lexicographical_cmp(InputIt1 first1, InputIt1 last1, InputIt2 first2, InputIt2 last2, Compare comp)
Lexicographical three-way comparison between two ranges.
bool any_of(const Range &r)
boost::iterator_range< Iterator > initial_sorted_range(Iterator begin, Iterator end, Pred pred, Less less)
The longest initial range of elements matching the predicate.
bool same_domain(const Container &x, const Container &y)
Check that two associative containers have the same keys.
Container::value_type min_forward(const Container &container, Comp comp)
Same as *std::max_element, but works with an input iterator, not just a forward iterator.
bool none_of(const Range &r, Predicate p)
Container::value_type back(const Container &container)
The last member of this Container.
auto transform(const Container &c, Fun &&fun)
Map a unary function on a container of values, and return the vector the results. ...
Provide a variadic mul on top of a binary mul(), and one().
Container::value_type max_forward(const Container &container)
Same as *std::max_element, but works with an input iterator, not just a forward iterator.
void erase_if(Container &c, Predicate p)
In place removal of entries matching the predicate.
Container set_intersection(const Container &s1, const Container &s2)
The intersection of two sets.
Container::value_type front(const Container &container)
The first member of this Container.
bool none_of_equal(const Range &r, const Value &value)
Container set_union(const Container &s1, const Container &s2)
The union of two sets.
Functor to compare Values of ValueSets.
bool is_sorted_forward(const Container &container, Compare comp)
Same as std::is_sorted, but works with an input iterator, not just a forward iterator.
Container set_difference(const Container &s1, const Container &s2)
The set of members of s1 that are not members of s2.