Simple Lua
A Simple C++ Lua Wrapper
Loading...
Searching...
No Matches
CompileTime.hpp
1#pragma once
2
3#include <cstdlib>
4#include <type_traits>
5#include <cstddef>
6#include <utility>
7
8namespace SL::Util::CompileTime
9{
10 // https://stackoverflow.com/questions/54268425/enumerating-over-a-fold-expression
11 template<std::size_t... inds, class F>
12 constexpr void static_for_impl(std::index_sequence<inds...>, F&& f)
13 {
14 (f(std::integral_constant<std::size_t, inds>{}), ...);
15 }
16
17 template<std::size_t N, class F>
18 constexpr void static_for(F&& f)
19 {
20 static_for_impl(std::make_index_sequence<N>{}, std::forward<F>(f));
21 }
22
23 template<int N, typename... Ts>
24 using NthType = typename std::tuple_element<N, std::tuple<Ts...>>::type;
25}