summaryrefslogtreecommitdiffhomepage
path: root/compat/iota.hpp
blob: 91ad759c1d0027121133f404d8428f69080428ed (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
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