25namespace bio::meta::list_traits::detail
33template <ptrdiff_t idx,
typename... pack_t>
40template <
typename... pack_t>
47template <
typename... pack_t>
55template <
typename... pack1_t,
typename... pack2_t>
56type_list<pack1_t..., pack2_t...>
concat(type_list<pack1_t...>, type_list<pack2_t...>);
64template <
typename... pack1_t,
typename... pack2_t,
typename... more_lists_t>
65auto concat(type_list<pack1_t...>, type_list<pack2_t...>, more_lists_t...)
67 return concat(type_list<pack1_t..., pack2_t...>{}, more_lists_t{}...);
74template <
typename... pack_t>
75meta::detail::pack_traits::drop_front<pack_t...>
drop_front(type_list<pack_t...>);
82template <
template <
typename>
typename trait_t,
typename... pack_t>
83meta::detail::pack_traits::transform<trait_t, pack_t...>
transform(type_list<pack_t...>);
90template <ptrdiff_t idx,
typename... pack1_t>
91meta::detail::pack_traits::split_after<idx, pack1_t...>
split_after(type_list<pack1_t...>);
98template <
size_t count,
typename t>
101 if constexpr (count == 0)
102 return type_list<>{};
103 else if constexpr (count == 1)
104 return type_list<t>{};
105 else if constexpr (count == 2)
106 return type_list<t, t>{};
107 else if constexpr (count == 3)
108 return type_list<t, t, t>{};
109 else if constexpr (count == 4)
110 return type_list<t, t, t, t>{};
111 else if constexpr (count == 5)
112 return type_list<t, t, t, t, t>{};
114 return concat(repeat<5, t>(), repeat<count - 5, t>());
123template <
typename replace_t, ptrdiff_t idx,
typename... pack_t>
124meta::detail::pack_traits::replace_at<replace_t, idx, pack_t...>
replace_at(type_list<pack_t...>);
127inline constexpr type_list<>
reverse(type_list<>)
133template <
typename head_t,
typename... pack_t>
134auto reverse(type_list<head_t, pack_t...>)
136 return concat(
reverse(type_list<pack_t...>{}), type_list<head_t>{});
140template <
typename... current_list_t>
141constexpr type_list<current_list_t...> type_list_difference(type_list<current_list_t...>, type_list<>)
147template <
typename... current_list_t,
typename remove_t,
typename... remove_list_t>
148constexpr auto type_list_difference(meta::type_list<current_list_t...>, meta::type_list<remove_t, remove_list_t...>)
150 constexpr auto pos = meta::detail::pack_traits::find<remove_t, current_list_t...>;
151 if constexpr (pos >= 0)
153 using split_list_t = meta::detail::pack_traits::split_after<pos, current_list_t...>;
155 using split_list1_t =
typename split_list_t::first_type;
156 using split_list2_t =
decltype(
drop_front(
typename split_list_t::second_type{}));
157 using filtered_list_t =
decltype(
concat(split_list1_t{}, split_list2_t{}));
158 return type_list_difference(filtered_list_t{}, meta::type_list<remove_t, remove_list_t...>{});
163 using filtered_list_t = meta::type_list<current_list_t...>;
164 return type_list_difference(filtered_list_t{}, meta::type_list<remove_list_t...>{});
183template <
typename list_t>
184 requires template_specialisation_of<list_t, meta::type_list>
185inline constexpr size_t size = 0;
199template <
typename... pack_t>
200inline constexpr size_t size<
type_list<pack_t...>> =
sizeof...(pack_t);
203template <
typename query_t,
typename list_t>
204 requires template_specialisation_of<list_t, meta::type_list>
205inline constexpr ptrdiff_t count = -1;
219template <
typename query_t,
typename... pack_t>
220inline constexpr ptrdiff_t count<query_t,
type_list<pack_t...>> = meta::detail::pack_traits::count<query_t, pack_t...>;
223template <
typename query_t,
typename list_t>
224 requires template_specialisation_of<list_t, meta::type_list>
225inline constexpr ptrdiff_t find = -1;
239template <
typename query_t,
typename... pack_t>
240inline constexpr ptrdiff_t find<query_t,
type_list<pack_t...>> =
241 meta::detail::pack_traits::detail::find<query_t, pack_t...>();
244template <
template <
typename>
typename pred_t,
typename list_t>
245 requires template_specialisation_of<list_t, meta::type_list>
246inline constexpr ptrdiff_t find_if = -1;
265template <
template <
typename>
typename pred_t,
typename... pack_t>
266inline constexpr ptrdiff_t find_if<pred_t,
type_list<pack_t...>> =
267 meta::detail::pack_traits::detail::find_if<pred_t, pack_t...>();
280template <
typename query_t,
typename list_t>
281 requires template_specialisation_of<list_t, meta::type_list>
282inline constexpr bool contains = (find<query_t, list_t> != -1);
306template <ptrdiff_t
idx,
typename list_t>
307 requires((template_specialisation_of<list_t, meta::type_list>) &&
308 ((idx >= 0 && idx < size<list_t>) || (-idx <= size<list_t>)))
309using at =
typename decltype(detail::at<idx>(list_t{}))::type;
324template <
typename list_t>
325 requires((template_specialisation_of<list_t, meta::type_list>) && (size<list_t> > 0))
326using front =
typename decltype(detail::front(list_t{}))::type;
344template <
typename list_t>
345 requires((template_specialisation_of<list_t, meta::type_list>) && (size<list_t> > 0))
346using back =
typename decltype(detail::back(list_t{}))::type;
370template <
typename... lists_t>
371 requires((template_specialisation_of<lists_t, meta::type_list> && ...))
372using concat =
decltype(detail::concat(lists_t{}...));
387template <
typename list_t>
388 requires((template_specialisation_of<list_t, meta::type_list>) && (size<list_t> > 0))
405template <ptrdiff_t i,
typename list_t>
406 requires((template_specialisation_of<list_t, meta::type_list>) && (i >= 0 && i <= size<list_t>))
407using take =
typename decltype(detail::split_after<i>(list_t{}))::first_type;
423template <ptrdiff_t i,
typename list_t>
424 requires((template_specialisation_of<list_t, meta::type_list>) && (i >= 0 && i <= size<list_t>))
425using drop =
typename decltype(detail::split_after<i>(list_t{}))::second_type;
441template <ptrdiff_t i,
typename list_t>
442 requires((template_specialisation_of<list_t, meta::type_list>) && (i >= 0 && i <= size<list_t>))
459template <ptrdiff_t i,
typename list_t>
460 requires((template_specialisation_of<list_t, meta::type_list>) && (i >= 0 && i <= size<list_t>))
477template <ptrdiff_t i,
typename list_t>
478 requires((template_specialisation_of<list_t, meta::type_list>) && (i >= 0 && i <= size<list_t>))
498template <
template <
typename>
typename trait_t,
typename list_t>
499 requires template_specialisation_of<list_t, meta::type_list>
500using transform =
decltype(detail::transform<trait_t>(list_t{}));
517template <
typename replace_t, std::ptrdiff_t i,
typename list_t>
518 requires((template_specialisation_of<list_t, meta::type_list>) && (i >= 0 && i < size<list_t>))
519using replace_at =
decltype(detail::replace_at<replace_t, i>(list_t{}));
533template <
size_t count,
typename t>
534using repeat =
decltype(detail::repeat<count, t>());
constexpr auto size
A type trait that holds the size of a (semi-)alphabet.
Definition: concept.hpp:517
Provides various traits for template packs.
Provides bio::meta::type_list.