Add IndexSequence and make_index_sequence utilities
This commit is contained in:
parent
31267675b9
commit
f88e873f55
22
src/utils.hh
22
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
|
||||
|
|
Loading…
Reference in New Issue
Block a user