diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/utils.hh | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/src/utils.hh b/src/utils.hh index fbf39e10..c441cdf3 100644 --- a/src/utils.hh +++ b/src/utils.hh @@ -14,6 +14,28 @@ std::unique_ptr<T> make_unique(Args&&... args) return std::unique_ptr<T>(new T(std::forward<Args>(args)...)); } +template<size_t... I> +struct IndexSequence +{ + using Next = IndexSequence<I..., sizeof...(I)>; +}; + +template<size_t N> +struct MakeIndexSequence +{ + using Type = typename MakeIndexSequence<N-1>::Type::Next; +}; + +template<> +struct MakeIndexSequence<0> +{ + using Type = IndexSequence<>; +}; + +template<size_t N> +constexpr typename MakeIndexSequence<N>::Type +make_index_sequence() { return typename MakeIndexSequence<N>::Type{}; } + // *** Singleton *** // // Singleton helper class, every singleton type T should inherit |
