25namespace bio::meta::detail::pack_traits::detail
34template <
typename query_t,
typename... pack_t>
35constexpr ptrdiff_t find()
38 return ((std::is_same_v<query_t, pack_t> ?
false : ++i) && ...) ? -1 : i;
47template <
template <
typename>
typename pred_t,
typename... pack_t>
48constexpr ptrdiff_t find_if()
51 return ((pred_t<pack_t>::value ?
false : ++i) && ...) ? -1 : i;
60template <ptrdiff_t idx,
typename head_t,
typename... tail_t>
63 if constexpr (idx == 0)
65 else if constexpr (idx > 0)
69 return at<idx - 1, tail_t...>();
72 return at<
sizeof...(tail_t) + 1 + idx, head_t, tail_t...>();
80template <
typename head_t,
typename... tail_t>
88template <
typename head_t,
typename... tail_t>
98template <ptrdiff_t idx,
typename head_t,
typename... pack2_t,
typename... pack1_t>
101 if constexpr (idx ==
sizeof...(pack2_t) + 1)
102 return std::pair<type_list<pack1_t..., head_t, pack2_t...>, type_list<>>{};
103 else if constexpr (idx == 0)
104 return std::pair<type_list<pack1_t...>, type_list<head_t, pack2_t...>>{};
106 return split_after<idx - 1, pack2_t...>(type_list<pack1_t..., head_t>{});
116template <
typename replace_t, ptrdiff_t idx,
typename... pack_t,
size_t... i>
125namespace bio::meta::detail::pack_traits
146template <
typename... pack_t>
147inline constexpr size_t size =
sizeof...(pack_t);
164template <
typename query_t,
typename... pack_t>
165inline constexpr ptrdiff_t count = (std::is_same_v<query_t, pack_t> + ... + 0);
182template <
typename query_t,
typename... pack_t>
183inline constexpr ptrdiff_t find = detail::find<query_t, pack_t...>();
205template <
template <
typename>
typename pred_t,
typename... pack_t>
206inline constexpr ptrdiff_t find_if = detail::find_if<pred_t, pack_t...>();
223template <
typename query_t,
typename... pack_t>
224inline constexpr bool contains = (find<query_t, pack_t...> != -1);
247template <ptrdiff_t idx,
typename... pack_t>
248 requires((idx >= 0 && idx <
sizeof...(pack_t)) || (-idx <=
sizeof...(pack_t)))
249using at =
typename decltype(detail::at<idx, pack_t...>())::type;
264template <
typename... pack_t>
265 requires(
sizeof...(pack_t) > 0)
266using front = typename decltype(detail::front<pack_t...>())::type;
284template <typename... pack_t>
285 requires(sizeof...(pack_t) > 0)
286using back = typename decltype((
std::type_identity<pack_t>{}, ...))::type;
307template <
typename... pack_t>
308 requires(
sizeof...(pack_t) > 0)
309using drop_front = typename decltype(detail::drop_front<pack_t...>())::type;
328template <template <typename> typename trait_t, typename... pack_t>
329using transform = type_list<trait_t<pack_t>...>;
351template <ptrdiff_t i, typename... pack_t>
352 requires(i >= 0 && i <= size<pack_t...>)
353using take = typename decltype(detail::split_after<i, pack_t...>(type_list<>{}))::first_type;
369template <ptrdiff_t i,
typename... pack_t>
370 requires(i >= 0 && i <=
size<pack_t...>)
371using drop =
typename decltype(detail::split_after<i, pack_t...>(type_list<>{}))::second_type;
387template <ptrdiff_t i,
typename... pack_t>
388 requires(i >= 0 && i <=
size<pack_t...>)
389using take_last = drop<size<pack_t...> - i, pack_t...>;
405template <ptrdiff_t i, typename... pack_t>
406 requires(i >= 0 && i <= size<pack_t...>)
423template <ptrdiff_t i,
typename... pack_t>
424 requires(i >= 0 && i <=
size<pack_t...>)
425using split_after =
decltype(detail::split_after<i, pack_t...>(type_list<>{}));
442template <
typename replace_t,
std::ptrdiff_t i,
typename... pack_t>
443 requires(i >= 0 && i <
size<pack_t...>)
444using replace_at =
decltype(detail::replace_at<replace_t, i, pack_t...>(
std::make_index_sequence<size<pack_t...>>{}));
constexpr auto size
A type trait that holds the size of a (semi-)alphabet.
Definition: concept.hpp:517
Provides bio::meta::type_list.