Add IndexSequence and make_index_sequence utilities

This commit is contained in:
Maxime Coste 2015-02-28 17:08:19 +00:00
parent 31267675b9
commit f88e873f55

View File

@ -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