From f88e873f55362bdc85b1461cf573e8cd3fc087fa Mon Sep 17 00:00:00 2001 From: Maxime Coste Date: Sat, 28 Feb 2015 17:08:19 +0000 Subject: [PATCH] Add IndexSequence and make_index_sequence utilities --- src/utils.hh | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) 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 make_unique(Args&&... args) return std::unique_ptr(new T(std::forward(args)...)); } +template +struct IndexSequence +{ + using Next = IndexSequence; +}; + +template +struct MakeIndexSequence +{ + using Type = typename MakeIndexSequence::Type::Next; +}; + +template<> +struct MakeIndexSequence<0> +{ + using Type = IndexSequence<>; +}; + +template +constexpr typename MakeIndexSequence::Type +make_index_sequence() { return typename MakeIndexSequence::Type{}; } + // *** Singleton *** // // Singleton helper class, every singleton type T should inherit