1 /* Copyright (C) 2016 Murray Cumming
3 * This program is free software: you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation, either version 3 of the License, or
6 * (at your option) any later version.
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/
17 #ifndef SIGC_TUPLE_UTILS_TUPLE_CDR_H
18 #define SIGC_TUPLE_UTILS_TUPLE_CDR_H
21 #include <type_traits>
29 * Get the type of a tuple without the first item.
32 struct tuple_type_cdr; // primary template is not defined
34 // Partial specialization for tuples of at least one element:
35 template <typename H, typename... T>
36 struct tuple_type_cdr<std::tuple<H, T...>>
38 using type = std::tuple<T...>;
43 template <typename T, std::size_t... I>
46 tuple_cdr_impl(T&& t, std::index_sequence<0, I...>)
48 using cdr = typename tuple_type_cdr<std::decay_t<T>>::type;
49 return cdr(std::get<I>(std::forward<T>(t))...);
55 * Get the a tuple without the first item.
56 * This is analogous to std::tuple_cat().
62 //We use std::decay_t<> because tuple_size is not defined for references.
63 constexpr auto size = std::tuple_size<std::decay_t<T>>::value;
65 static_assert(size != 0, "tuple size must be non-zero");
66 using seq = std::make_index_sequence<size>;
67 return detail::tuple_cdr_impl(std::forward<T>(t), seq{});
70 } // namespace internal
74 #endif //SIGC_TUPLE_UTILS_TUPLE_CDR_H