Last active
August 29, 2015 14:24
-
-
Save SilverIce/3c16b05a28c2d7d49853 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
template <size_t N> struct index_tuple_from_N; | |
template <size_t... I> struct index_tuple_t { | |
enum { | |
count = sizeof... (I), | |
last = count - 1, | |
first = 0, | |
}; | |
using grow = index_tuple_t < I ..., last + 1 > ; | |
using shrink = typename index_tuple_from_N < count - 1 >::make ; | |
}; | |
template <size_t N> struct index_tuple_from_N { | |
using make = typename index_tuple_from_N<N - 1>::make::grow; | |
}; | |
template <> struct index_tuple_from_N<1> { | |
using make = index_tuple_t < 0 > ; | |
}; | |
template <> struct index_tuple_from_N<0> { | |
using make = void; // A trick to shut up the compiler. Actually it never reaches this 'make' | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment