/* Copyright (C) 2016 Murray Cumming
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3.0 of the License, or (at your option) any later version.
*
* This library 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, see .
*/
#ifndef SIGC_TUPLE_UTILS_TUPLE_CDR_H
#define SIGC_TUPLE_UTILS_TUPLE_CDR_H
#include
#include
#include
namespace sigc::internal
{
/**
* Get the type of a tuple without the first item.
*/
template
struct tuple_type_cdr; // primary template is not defined
// Partial specialization for tuples of at least one element:
template
struct tuple_type_cdr>
{
using type = std::tuple;
};
namespace detail
{
template
constexpr decltype(auto)
tuple_cdr_impl(T&& t, std::index_sequence<0, I...>)
{
using cdr = typename tuple_type_cdr>::type;
return cdr(std::get(std::forward(t))...);
}
} // detail namespace
/**
* Get the a tuple without the first item.
* This is analogous to std::tuple_cat().
*/
template
constexpr decltype(auto)
tuple_cdr(T&& t)
{
// We use std::decay_t<> because tuple_size is not defined for references.
constexpr auto size = std::tuple_size>::value;
static_assert(size != 0, "tuple size must be non-zero");
using seq = std::make_index_sequence;
return detail::tuple_cdr_impl(std::forward(t), seq{});
}
} // namespace sigc::internal
#endif // SIGC_TUPLE_UTILS_TUPLE_CDR_H