Created
December 9, 2014 15:22
-
-
Save windoze/6500832f435df0c87951 to your computer and use it in GitHub Desktop.
make_tuple_indices extracts elements from tuple
This file contains hidden or 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 <std::size_t...> struct tuple_indices {}; | |
template <std::size_t Sp, class IntTuple, std::size_t Ep> struct make_indices_imp; | |
template <std::size_t Sp, std::size_t... Indices, std::size_t Ep> | |
struct make_indices_imp<Sp, tuple_indices<Indices...>, Ep> | |
{ typedef typename make_indices_imp<Sp+1, tuple_indices<Indices..., Sp>, Ep>::type type; }; | |
template <std::size_t Ep, std::size_t... Indices> | |
struct make_indices_imp<Ep, tuple_indices<Indices...>, Ep> | |
{ typedef tuple_indices<Indices...> type; }; | |
template <std::size_t Ep, std::size_t Sp = 0> | |
struct make_tuple_indices { | |
static_assert(Sp <= Ep, "make_tuple_indices input error"); | |
typedef typename make_indices_imp<Sp, tuple_indices<>, Ep>::type type; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment