summaryrefslogtreecommitdiff
path: root/src/include/tome/make_array.hpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/include/tome/make_array.hpp')
-rw-r--r--src/include/tome/make_array.hpp13
1 files changed, 13 insertions, 0 deletions
diff --git a/src/include/tome/make_array.hpp b/src/include/tome/make_array.hpp
new file mode 100644
index 00000000..23cb8ac0
--- /dev/null
+++ b/src/include/tome/make_array.hpp
@@ -0,0 +1,13 @@
+#pragma once
+
+#include <type_traits>
+
+/*
+ * Make an array of a POD type.
+ */
+template <typename T> T *make_array(std::size_t n) {
+ static_assert(std::is_pod<T>::value, "Type parameter must be POD type");
+ T *array = new T[n];
+ memset(array, 0, n*sizeof(T));
+ return array;
+}