mirror of
https://github.com/wheremyfoodat/Panda3DS.git
synced 2025-06-07 03:21:38 +12:00
Making helpers.hpp thinner
This commit is contained in:
parent
3cf8427670
commit
432b4b847b
3 changed files with 17 additions and 58 deletions
16
include/metaprogramming.hpp
Normal file
16
include/metaprogramming.hpp
Normal file
|
@ -0,0 +1,16 @@
|
|||
#pragma once
|
||||
#include <type_traits>
|
||||
#include <utility>
|
||||
|
||||
namespace Helpers {
|
||||
/// Used to make the compiler evaluate beeg loops at compile time for things like generating compile-time tables
|
||||
template <typename T, T Begin, class Func, T... Is>
|
||||
static constexpr void static_for_impl(Func&& f, std::integer_sequence<T, Is...>) {
|
||||
(f(std::integral_constant<T, Begin + Is>{}), ...);
|
||||
}
|
||||
|
||||
template <typename T, T Begin, T End, class Func>
|
||||
static constexpr void static_for(Func&& f) {
|
||||
static_for_impl<T, Begin>(std::forward<Func>(f), std::make_integer_sequence<T, End - Begin>{});
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue