Last active
November 27, 2016 22:27
-
-
Save picanumber/852be541e540981ebf400bc2e8816fbc 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
namespace detail | |
{ | |
template <std::size_t Ofst, class Tuple, std::size_t... I> | |
constexpr auto slice_impl(Tuple&& t, std::index_sequence<I...>) | |
{ | |
return std::forward_as_tuple( | |
std::get<I + Ofst>(std::forward<Tuple>(t))...); | |
} | |
} | |
template <std::size_t I1, std::size_t I2, class Cont> | |
constexpr auto tuple_slice(Cont&& t) | |
{ | |
static_assert(I2 >= I1, "invalid slice"); | |
static_assert(std::tuple_size<std::decay_t<Cont>>::value >= I2, | |
"slice index out of bounds"); | |
return detail::slice_impl<I1>(std::forward<Cont>(t), | |
std::make_index_sequence<I2 - I1>{}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment