diff options
| author | Maxime Coste <frrrwww@gmail.com> | 2015-05-26 18:42:09 +0100 |
|---|---|---|
| committer | Maxime Coste <frrrwww@gmail.com> | 2015-05-26 18:42:09 +0100 |
| commit | 993e842fdff8fd6a909c2f525cfc006257eedd57 (patch) | |
| tree | 1ce0eff435db35f3ee5370b9949d42bb51e31180 /src/utils.hh | |
| parent | 499bde10bdef43b8621ccd5b277d7a475b4f8fe7 (diff) | |
Retreat ! go back to C++11 only code
This reverts commit b42de850314e7d76f873ddc7d64c5f7d2a30eb00.
Diffstat (limited to 'src/utils.hh')
| -rw-r--r-- | src/utils.hh | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/src/utils.hh b/src/utils.hh index 7a7eb071..ee2591c0 100644 --- a/src/utils.hh +++ b/src/utils.hh @@ -8,6 +8,34 @@ namespace Kakoune { +template<typename T, typename... Args> +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 |
