Browse Source

Fix `extend` to work with range sentinels

default_compile_flags
vector-of-bool 5 years ago
parent
commit
24b5b0c92f
1 changed files with 14 additions and 2 deletions
  1. +14
    -2
      src/dds/util/algo.hpp

+ 14
- 2
src/dds/util/algo.hpp View File

@@ -11,9 +11,21 @@ void erase_if(Container& c, Predicate&& p) {
c.erase(erase_point, c.end());
}

template <typename Container, typename Iter, typename Stop>
void extend(Container& c, Iter iter, const Stop stop) {
while (iter != stop) {
c.insert(c.end(), typename Container::value_type(*iter++));
}
}

template <typename Container, typename Iter>
void extend(Container& c, Iter iter, Iter end) {
c.insert(c.end(), iter, end);
}

template <typename Container, typename Other>
void extend(Container& c, const Other& o) {
c.insert(c.end(), o.begin(), o.end());
void extend(Container& c, Other&& o) {
extend(c, o.begin(), o.end());
}

template <typename Container, typename Item>

Loading…
Cancel
Save