summaryrefslogtreecommitdiffhomepage
path: root/compat
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2024-05-24 11:59:48 +0200
committerStanislaw Halik <sthalik@misaki.pl>2024-05-25 22:59:05 +0200
commit83f60aa9a5a2452158b7774044dcc51c82c43ae4 (patch)
treee7354aa1b76ecb2c8f6ca34bcd40e8059b937b08 /compat
parent36972e30f7f2c47e3a5e45b94cda5e0072839484 (diff)
w
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