24namespace seqan3::pack_traits::detail
33template <
typename query_t,
typename... pack_t>
34constexpr ptrdiff_t
find()
37 return ((std::is_same_v<query_t, pack_t> ?
false : ++i) && ...) ? -1 : i;
46template <
template <
typename>
typename pred_t,
typename... pack_t>
50 return ((pred_t<pack_t>::value ?
false : ++i) && ...) ? -1 : i;
59template <ptrdiff_t idx,
typename head_t,
typename... tail_t>
62 if constexpr (idx == 0)
64 else if constexpr (idx > 0)
68 return at<idx - 1, tail_t...>();
71 return at<
sizeof...(tail_t) + 1 + idx, head_t, tail_t...>();
79template <
typename head_t,
typename... tail_t>
87template <
typename head_t,
typename... tail_t>
97template <ptrdiff_t idx,
typename head_t,
typename... pack2_t,
typename... pack1_t>
100 if constexpr (idx ==
sizeof...(pack2_t) + 1)
101 return std::pair<type_list<pack1_t..., head_t, pack2_t...>, type_list<>>{};
102 else if constexpr (idx == 0)
103 return std::pair<type_list<pack1_t...>, type_list<head_t, pack2_t...>>{};
105 return split_after<idx - 1, pack2_t...>(type_list<pack1_t..., head_t>{});
115template <
typename replace_t, ptrdiff_t idx,
typename... pack_t,
size_t... i>
145template <
typename... pack_t>
146inline constexpr size_t size =
sizeof...(pack_t);
163template <
typename query_t,
typename... pack_t>
164inline constexpr ptrdiff_t
count = (std::is_same_v<query_t, pack_t> + ... + 0);
181template <
typename query_t,
typename... pack_t>
182inline constexpr ptrdiff_t
find = seqan3::pack_traits::detail::find<query_t, pack_t...>();
204template <
template <
typename>
typename pred_t,
typename... pack_t>
205inline constexpr ptrdiff_t
find_if = seqan3::pack_traits::detail::find_if<pred_t, pack_t...>();
222template <
typename query_t,
typename... pack_t>
246template <ptrdiff_t idx,
typename... pack_t>
247 requires (idx >= 0 && idx <
sizeof...(pack_t)) || (-idx <=
sizeof...(pack_t))
248using at =
typename decltype(detail::at<idx, pack_t...>())::type;
263template <
typename... pack_t>
264 requires (
sizeof...(pack_t) > 0)
265using front =
typename decltype(detail::front<pack_t...>())::type;
283template <
typename... pack_t>
284 requires (
sizeof...(pack_t) > 0)
306template <
typename... pack_t>
307 requires (
sizeof...(pack_t) > 0)
308using drop_front =
typename decltype(detail::drop_front<pack_t...>())::type;
327template <
template <
typename>
typename trait_t,
typename... pack_t>
350template <ptrdiff_t i,
typename... pack_t>
351 requires (i >= 0 && i <=
size<pack_t...>)
352using take =
typename decltype(detail::split_after<i, pack_t...>(
type_list<>{}))::first_type;
368template <ptrdiff_t i,
typename... pack_t>
369 requires (i >= 0 && i <=
size<pack_t...>)
370using drop =
typename decltype(detail::split_after<i, pack_t...>(
type_list<>{}))::second_type;
386template <ptrdiff_t i,
typename... pack_t>
387 requires (i >= 0 && i <=
size<pack_t...>)
404template <ptrdiff_t i, typename... pack_t>
405 requires (i >= 0 && i <= size<pack_t...>)
422template <ptrdiff_t i,
typename... pack_t>
423 requires (i >= 0 && i <=
size<pack_t...>)
441template <
typename replace_t,
std::ptrdiff_t i,
typename... pack_t>
442 requires (i >= 0 && i <
size<pack_t...>)
decltype(detail::replace_at< replace_t, i, pack_t... >(std::make_index_sequence< size< pack_t... > >{})) replace_at
Replace the type at the given index with the given type.
Definition: traits.hpp:443
take< size< pack_t... > - i, pack_t... > drop_last
Return a seqan3::type_list of the types the type pack, except the last n.
Definition: traits.hpp:406
typename decltype(detail::drop_front< pack_t... >())::type drop_front
Return a seqan3::type_list of all the types in the type pack, except the first.
Definition: traits.hpp:308
typename decltype((std::type_identity< pack_t >{},...))::type back
Return the last type from the type pack.
Definition: traits.hpp:285
constexpr ptrdiff_t find
Get the index of the first occurrence of a type in a pack.
Definition: traits.hpp:182
constexpr ptrdiff_t count
Count the occurrences of a type in a pack.
Definition: traits.hpp:164
typename decltype(detail::at< idx, pack_t... >())::type at
Return the type at given index from the type pack.
Definition: traits.hpp:248
decltype(detail::split_after< i, pack_t... >(type_list<>{})) split_after
Split a type pack into two parts returned as a pair of seqan3::type_list.
Definition: traits.hpp:424
typename decltype(detail::front< pack_t... >())::type front
Return the first type from the type pack.
Definition: traits.hpp:265
typename decltype(detail::split_after< i, pack_t... >(type_list<>{}))::second_type drop
Return a seqan3::type_list of the types in the type pack, except the first n.
Definition: traits.hpp:370
constexpr size_t size
The size of a type pack.
Definition: traits.hpp:146
drop< size< pack_t... > - i, pack_t... > take_last
Return a seqan3::type_list of the last n types in the type pack.
Definition: traits.hpp:388
typename decltype(detail::split_after< i, pack_t... >(type_list<>{}))::first_type take
Return a seqan3::type_list of the first n types in the type pack.
Definition: traits.hpp:352
constexpr ptrdiff_t find_if
Get the index of the first type in a pack that satisfies the given predicate.
Definition: traits.hpp:205
constexpr bool contains
Whether a type occurs in a pack or not.
Definition: traits.hpp:223
Namespace containing traits for working on type packs.
Type that contains multiple types.
Definition: type_list.hpp:29
Provides seqan3::type_list.