Molybden API
Loading...
Searching...
No Matches
integer_sequence.hpp
1// Copyright (c) 2000-2024 TeamDev. All rights reserved.
2// TeamDev PROPRIETARY and CONFIDENTIAL.
3// Use is subject to license terms.
4
5#ifndef MOLYBDEN_INTEGER_SEQUENCE_HPP
6#define MOLYBDEN_INTEGER_SEQUENCE_HPP
7
8#include <cstddef>
9
10namespace molybden {
11namespace internal {
12
23template <typename T, T... Ints>
24struct integer_sequence {
25 using value_type = T;
26
27 static constexpr std::size_t size() { return sizeof...(Ints); }
28};
29
30template <std::size_t... Ints>
31using index_sequence = integer_sequence<std::size_t, Ints...>;
32
33template <typename T, std::size_t N, T... Is>
34struct make_integer_sequence : make_integer_sequence<T, N - 1, N - 1, Is...> {};
35
36template <typename T, T... Is>
37struct make_integer_sequence<T, 0, Is...> : integer_sequence<T, Is...> {};
38
39template <std::size_t N>
40using make_index_sequence = make_integer_sequence<std::size_t, N>;
41
42template <typename... T>
43using index_sequence_for = make_index_sequence<sizeof...(T)>;
44
45} // namespace internal
46} // namespace molybden
47
48#endif // MOLYBDEN_INTEGER_SEQUENCE_HPP