Skip to content

Commit

Permalink
libcore: Added a container mapping template method
Browse files Browse the repository at this point in the history
  • Loading branch information
skyjake committed Oct 20, 2018
1 parent ce19b28 commit f6b3a41
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions doomsday/sdk/libcore/include/de/libcore.h
Expand Up @@ -630,6 +630,19 @@ inline ContainerType map(ContainerType const &c,
return out;
}

template <typename OutContainer,
typename InContainer,
typename Func,
typename Inserter = std::back_insert_iterator<OutContainer>>
inline OutContainer map(const InContainer &input, Func func) {
OutContainer out;
Inserter ins(out);
for (const auto &i : input) {
*ins++ = func(i);
}
return out;
}

template <typename ContainerType>
inline ContainerType filter(ContainerType const &c,
std::function<bool (typename ContainerType::value_type const &)> func) {
Expand Down

0 comments on commit f6b3a41

Please sign in to comment.