summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/collections.hpp21
1 files changed, 21 insertions, 0 deletions
diff --git a/lib/collections.hpp b/lib/collections.hpp
index ad4d947..5f4be68 100644
--- a/lib/collections.hpp
+++ b/lib/collections.hpp
@@ -12,3 +12,24 @@ operator+(const std::array<T, first> & a, const std::array<T, second> & b)
std::copy(b.begin(), b.end(), out);
return r;
}
+
+template<typename T, std::size_t N>
+auto
+operator*(const std::array<T, N> & in, auto && f)
+{
+ std::array<decltype(f(in[0])), N> out;
+
+ for (auto outitr = out.begin(); const auto & v : in) {
+ *outitr++ = f(v);
+ }
+ return out;
+}
+
+template<typename T, std::size_t N>
+auto &
+operator*=(std::array<T, N> & in, auto && f)
+{
+ for (const auto & v : in) {
+ f(v);
+ }
+}