summaryrefslogtreecommitdiffhomepage
path: root/compat
diff options
context:
space:
mode:
Diffstat (limited to 'compat')
-rw-r--r--compat/iota.hpp23
1 files changed, 23 insertions, 0 deletions
diff --git a/compat/iota.hpp b/compat/iota.hpp
new file mode 100644
index 00000000..91ad759c
--- /dev/null
+++ b/compat/iota.hpp
@@ -0,0 +1,23 @@
+#pragma once
+#include <array>
+
+namespace floormat::detail {
+
+template<typename Type, size_t Count>
+std::array<Type, Count> constexpr iota_array_()
+{
+ static_assert( size_t(Type(Count)) == Count );
+ std::array<Type, Count> ret;
+ for (size_t i = 0; i < Count; i++)
+ ret[i] = Type(i);
+ return ret;
+}
+
+} // namespace floormat::detail
+
+namespace floormat {
+
+template<typename Type, size_t Count>
+constexpr inline std::array<Type, Count> iota_array = detail::iota_array_<Type, Count>();
+
+} // namespace floormat