/* Copyright (C) 2016 Murray Cumming * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see #include namespace sigc { namespace internal { namespace detail { template struct tuple_type_start_impl; template struct tuple_type_start_impl> { using type = std::tuple::type...>; }; } // detail namespace /** * Get the type of a tuple with just the first @len items. */ template struct tuple_type_start : detail::tuple_type_start_impl> {}; namespace detail { template struct tuple_start_impl; template struct tuple_start_impl> { static constexpr decltype(auto) tuple_start(T&& t) { constexpr auto size = std::tuple_size>::value; constexpr auto len = sizeof...(I); static_assert(len <= size, "The tuple size must be less than or equal to the length."); using start = typename tuple_type_start, len>::type; return start(std::get(std::forward(t))...); } }; } // detail namespace /** * Get the tuple with the last @a len items of the original. */ template constexpr decltype(auto) // typename tuple_type_end::type tuple_start(T&& t) { //We use std::decay_t<> because tuple_size is not defined for references. constexpr auto size = std::tuple_size>::value; static_assert(len <= size, "The tuple size must be less than or equal to the length."); return detail::tuple_start_impl>::tuple_start( std::forward(t)); } } // namespace internal } // namespace sigc #endif //SIGC_TUPLE_UTILS_TUPLE_START_H