20 #ifndef CONDITIONAL_BACK_INSERTER_HPP_
21 #define CONDITIONAL_BACK_INSERTER_HPP_
28 template <
typename Container,
typename Predicate>
29 class conditional_back_insert_iterator:
public std::back_insert_iterator<Container> {
32 conditional_back_insert_iterator(Container& c, P&& p): std::back_insert_iterator<Container>(c), p(std::forward<P>(p)) {}
35 conditional_back_insert_iterator(
const conditional_back_insert_iterator& other):
36 std::back_insert_iterator<Container>(other), p(other.p) {}
37 conditional_back_insert_iterator& operator=(
const conditional_back_insert_iterator& other) {
38 std::back_insert_iterator<Container>::operator=(other);
43 conditional_back_insert_iterator& operator=(
const typename Container::value_type& value) {
44 if (p(value)) std::back_insert_iterator<Container>::operator=(value);
48 conditional_back_insert_iterator& operator=(
typename Container::value_type&& value) {
49 if (p(value)) std::back_insert_iterator<Container>::operator=(std::move(value));
53 conditional_back_insert_iterator& operator*() {
return *
this; }
54 conditional_back_insert_iterator& operator++() {
return *
this; }
55 conditional_back_insert_iterator& operator++(
int) {
return *
this; }
61 template<
typename Container,
typename Predicate>
62 conditional_back_insert_iterator<Container, Predicate> conditional_back_inserter(Container& c, Predicate&& p) {
63 return conditional_back_insert_iterator<Container, Predicate>(c, std::forward<Predicate>(p));
DataSketches namespace.
Definition: binomial_bounds.hpp:38