SeqAn3 3.4.0-rc.1
The Modern C++ library for sequence analysis.
Loading...
Searching...
No Matches
split.hpp
Go to the documentation of this file.
1// SPDX-FileCopyrightText: 2006-2024 Knut Reinert & Freie Universität Berlin
2// SPDX-FileCopyrightText: 2016-2024 Knut Reinert & MPI für molekulare Genetik
3// SPDX-License-Identifier: BSD-3-Clause
4
10#pragma once
11
12#include <utility>
13
16
17namespace seqan3::detail
18{
19
33template <size_t beg, template <typename...> typename tuple_t, size_t... Is, typename... ts>
34 requires tuple_like<tuple_t<ts...>> && tuple_like<tuple_t<>>
35constexpr auto tuple_split(tuple_t<ts...> const & t, std::index_sequence<Is...> const & SEQAN3_DOXYGEN_ONLY(idx))
36{
37#pragma GCC diagnostic push
38#pragma GCC diagnostic ignored "-Wmissing-braces"
39 return tuple_t<std::tuple_element_t<beg + Is, tuple_t<ts...>>...>{std::get<beg + Is>(t)...};
40#pragma GCC diagnostic pop
41}
42
44template <size_t beg, template <typename...> typename tuple_t, size_t... Is, typename... ts>
45 requires tuple_like<tuple_t<ts...>> && tuple_like<tuple_t<>>
46constexpr auto tuple_split(tuple_t<ts...> && t, std::index_sequence<Is...> const & SEQAN3_DOXYGEN_ONLY(idx))
47{
48#pragma GCC diagnostic push
49#pragma GCC diagnostic ignored "-Wmissing-braces"
50 return tuple_t<std::tuple_element_t<beg + Is, tuple_t<ts...>>...>{std::move(std::get<beg + Is>(t))...};
51#pragma GCC diagnostic pop
52}
53} // namespace seqan3::detail
54
55namespace seqan3
56{
85template <size_t pivot_c, template <typename...> typename tuple_t, typename... ts>
86 requires tuple_like<tuple_t<ts...>>
87constexpr auto tuple_split(tuple_t<ts...> const & t)
88{
89 static_assert(pivot_c <= sizeof...(ts));
90
91#pragma GCC diagnostic push
92#pragma GCC diagnostic ignored "-Wmissing-braces"
93 return tuple_t{detail::tuple_split<0>(t, std::make_index_sequence<pivot_c>{}),
94 detail::tuple_split<pivot_c>(t, std::make_index_sequence<sizeof...(ts) - pivot_c>{})};
95#pragma GCC diagnostic pop
96}
97
99template <size_t pivot_c, template <typename...> typename tuple_t, typename... ts>
100 requires tuple_like<tuple_t<ts...>>
101constexpr auto tuple_split(tuple_t<ts...> && t)
102{
103 static_assert(pivot_c <= sizeof...(ts));
104#pragma GCC diagnostic push
105#pragma GCC diagnostic ignored "-Wmissing-braces"
106 return tuple_t{detail::tuple_split<0>(std::move(t), std::make_index_sequence<pivot_c>{}),
107 detail::tuple_split<pivot_c>(std::move(t), std::make_index_sequence<sizeof...(ts) - pivot_c>{})};
108#pragma GCC diagnostic pop
109}
110
137template <typename pivot_t, tuple_like tuple_t>
138constexpr auto tuple_split(tuple_t && t)
139{
140 constexpr size_t pivot_c = list_traits::find<pivot_t, detail::tuple_type_list_t<std::remove_cvref_t<tuple_t>>>;
141
143
144 return tuple_split<pivot_c>(std::forward<tuple_t>(t));
145}
146
147} // namespace seqan3
A "pretty printer" for most SeqAn data structures and related types.
Definition debug_stream_type.hpp:79
constexpr auto tuple_split(tuple_t< ts... > const &t)
Splits a tuple like data structure at the given position.
Definition split.hpp:87
Whether a type behaves like a tuple.
The main SeqAn3 namespace.
Definition aligned_sequence_concept.hpp:26
Provides traits for seqan3::type_list.
Provides seqan3::tuple_like.
Hide me