summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/util.cpp1
-rw-r--r--lib/util.h14
2 files changed, 15 insertions, 0 deletions
diff --git a/lib/util.cpp b/lib/util.cpp
new file mode 100644
index 0000000..408a76a
--- /dev/null
+++ b/lib/util.cpp
@@ -0,0 +1 @@
+#include "util.h"
diff --git a/lib/util.h b/lib/util.h
new file mode 100644
index 0000000..290492f
--- /dev/null
+++ b/lib/util.h
@@ -0,0 +1,14 @@
+#pragma once
+
+#include <algorithm> // IWYU pragma: keep
+#include <array>
+#include <cstddef>
+
+template<typename T, std::size_t N>
+constexpr auto
+transform_array(const std::array<T, N> & in, auto && transform)
+{
+ std::array<decltype(transform(in.front())), N> out {};
+ std::transform(in.begin(), in.end(), out.begin(), transform);
+ return out;
+}