Skip to content

Instantly share code, notes, and snippets.

@SilverIce
Last active August 29, 2015 14:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save SilverIce/3c16b05a28c2d7d49853 to your computer and use it in GitHub Desktop.
Save SilverIce/3c16b05a28c2d7d49853 to your computer and use it in GitHub Desktop.
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