Loading...
Searching...
No Matches
split.hpp
Go to the documentation of this file.
// SPDX-FileCopyrightText: 2006-2025 Knut Reinert & Freie Universität Berlin
// SPDX-FileCopyrightText: 2016-2025 Knut Reinert & MPI für molekulare Genetik
// SPDX-License-Identifier: BSD-3-Clause
#pragma once
#include <utility>
#include <seqan3/utility/tuple/concept.hpp>
#include <seqan3/utility/type_list/traits.hpp>
namespace seqan3::detail
{
template <size_t beg, template <typename...> typename tuple_t, size_t... Is, typename... ts>
requires tuple_like<tuple_t<ts...>> && tuple_like<tuple_t<>>
constexpr auto tuple_split(tuple_t<ts...> const & t, std::index_sequence<Is...> const & SEQAN3_DOXYGEN_ONLY(idx))
{
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wmissing-braces"
return tuple_t<std::tuple_element_t<beg + Is, tuple_t<ts...>>...>{std::get<beg + Is>(t)...};
#pragma GCC diagnostic pop
}
template <size_t beg, template <typename...> typename tuple_t, size_t... Is, typename... ts>
requires tuple_like<tuple_t<ts...>> && tuple_like<tuple_t<>>
constexpr auto tuple_split(tuple_t<ts...> && t, std::index_sequence<Is...> const & SEQAN3_DOXYGEN_ONLY(idx))
{
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wmissing-braces"
return tuple_t<std::tuple_element_t<beg + Is, tuple_t<ts...>>...>{std::move(std::get<beg + Is>(t))...};
#pragma GCC diagnostic pop
}
} // namespace seqan3::detail
namespace seqan3
{
template <size_t pivot_c, template <typename...> typename tuple_t, typename... ts>
requires tuple_like<tuple_t<ts...>>
constexpr auto tuple_split(tuple_t<ts...> const & t)
{
static_assert(pivot_c <= sizeof...(ts));
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wmissing-braces"
return tuple_t{detail::tuple_split<0>(t, std::make_index_sequence<pivot_c>{}),
detail::tuple_split<pivot_c>(t, std::make_index_sequence<sizeof...(ts) - pivot_c>{})};
#pragma GCC diagnostic pop
}
template <size_t pivot_c, template <typename...> typename tuple_t, typename... ts>
requires tuple_like<tuple_t<ts...>>
constexpr auto tuple_split(tuple_t<ts...> && t)
{
static_assert(pivot_c <= sizeof...(ts));
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wmissing-braces"
return tuple_t{detail::tuple_split<0>(std::move(t), std::make_index_sequence<pivot_c>{}),
detail::tuple_split<pivot_c>(std::move(t), std::make_index_sequence<sizeof...(ts) - pivot_c>{})};
#pragma GCC diagnostic pop
}
template <typename pivot_t, tuple_like tuple_t>
constexpr auto tuple_split(tuple_t && t)
{
constexpr size_t pivot_c = list_traits::find<pivot_t, detail::tuple_type_list_t<std::remove_cvref_t<tuple_t>>>;
static_assert(pivot_c <= std::tuple_size_v<std::remove_cvref_t<tuple_t>>);
return tuple_split<pivot_c>(std::forward<tuple_t>(t));
}
} // namespace seqan3
std::forward
T forward(T... args)
seqan3::tuple_split
constexpr auto tuple_split(tuple_t< ts... > const &t)
Splits a tuple like data structure at the given position.
Definition split.hpp:87
std::make_index_sequence
tuple_like
Whether a type behaves like a tuple.
seqan3
The main SeqAn3 namespace.
Definition aligned_sequence_concept.hpp:26
traits.hpp
Provides traits for seqan3::type_list.
concept.hpp
Provides seqan3::tuple_like.
utility
Hide me