18 #include <meta/meta.hpp> 52 template <
typename tuple_t,
typename tuple_derived_t,
template <
typename>
typename fun_t,
typename other_t>
53 inline bool constexpr one_component_is =
false;
58 template <
typename ... tuple_comps,
59 typename tuple_derived_t,
60 template <
typename>
typename fun_t,
62 inline bool constexpr one_component_is<alphabet_tuple_base<tuple_derived_t, tuple_comps...>,
66 !
meta::empty<meta::find_if<meta::list<tuple_comps...>, fun_t<other_t>>>::value;
70 template <
typename ... tuple_comps,
71 typename tuple_derived_t,
72 template <
typename>
typename fun_t>
73 inline bool constexpr one_component_is<alphabet_tuple_base<tuple_derived_t, tuple_comps...>,
76 alphabet_tuple_base<tuple_derived_t, tuple_comps...>> =
false;
79 template <
typename ... tuple_comps,
80 typename tuple_derived_t,
81 template <
typename>
typename fun_t>
82 inline bool constexpr one_component_is<alphabet_tuple_base<tuple_derived_t, tuple_comps...>,
85 tuple_derived_t> =
false;
88 template <
typename ... tuple_comps,
89 typename tuple_derived_t,
90 template <
typename>
typename fun_t,
92 requires ConvertibleToByMember<other_t, tuple_derived_t>
93 inline bool constexpr one_component_is<alphabet_tuple_base<tuple_derived_t, tuple_comps...>,
99 template <
typename ... tuple_comps,
100 typename tuple_derived_t,
101 template <
typename>
typename fun_t,
103 requires type_in_pack_v<other_t, tuple_comps...>
106 inline bool constexpr one_component_is<alphabet_tuple_base<tuple_derived_t, tuple_comps...>,
113 template <
typename ... tuple_comps,
114 typename tuple_derived_t,
116 requires ImplicitlyConvertibleTo<other_t, tuple_derived_t>
117 inline bool constexpr one_component_is<alphabet_tuple_base<tuple_derived_t, tuple_comps...>,
119 weakly_equality_comparable_with,
121 template <
typename ... tuple_comps,
122 typename tuple_derived_t,
124 requires ImplicitlyConvertibleTo<other_t, tuple_derived_t>
125 inline bool constexpr one_component_is<alphabet_tuple_base<tuple_derived_t, tuple_comps...>,
138 template <
typename t>
139 decltype(
auto)
get();
142 decltype(auto)
get();
182 template <typename derived_type,
183 typename ...component_types>
185 requires (detail::WritableConstexprSemialphabet<component_types> && ...) &&
186 (!
std::is_reference_v<component_types> && ...)
196 (1 * ... * alphabet_size<component_types>),
200 using component_list = meta::list<component_types...>;
203 template <
typename type>
204 static constexpr
bool is_component =
205 meta::in<component_list, type>::value;
208 template <
typename type>
209 static constexpr
bool is_unique_component =
210 is_component<type> &&
211 (meta::find_index<component_list, type>::value == meta::reverse_find_index<component_list, type>::value);
217 template <
typename alphabet_type,
size_t index>
218 class component_proxy :
public alphabet_proxy<component_proxy<alphabet_type, index>, alphabet_type>
230 constexpr
void on_update() noexcept
234 - parent->template to_component_rank<index>() * alphabet_tuple_base::cummulative_alph_sizes[index]
235 +
to_rank() * alphabet_tuple_base::cummulative_alph_sizes[index]);
243 using typename base_t::phred_type;
250 using base_t::operator=;
255 constexpr component_proxy() :
base_t{}, parent{} {}
256 constexpr component_proxy(component_proxy
const &) =
default;
257 constexpr component_proxy(component_proxy &&) =
default;
258 constexpr component_proxy & operator=(component_proxy
const &) =
default;
259 constexpr component_proxy & operator=(component_proxy &&) =
default;
260 ~component_proxy() =
default;
280 using base_t::base_t;
294 using base_t::assign_rank;
298 using seqan3_tuple_components = component_list;
301 using seqan3_recursive_tuple_components =
302 meta::concat<component_list,
303 detail::transformation_trait_or_t<detail::recursive_tuple_components<component_types>,
328 template <
typename component_type>
330 requires is_unique_component<component_type>
334 get<component_type>(*this) = alph;
350 template <
typename indirect_component_type>
352 requires detail::one_component_is<alphabet_tuple_base, derived_type, detail::implicitly_convertible_from, indirect_component_type>
356 using component_type = meta::front<meta::find_if<component_list, detail::implicitly_convertible_from<indirect_component_type>>>;
357 component_type tmp(alph);
358 get<component_type>(*this) = tmp;
362 template <
typename indirect_component_type>
363 requires !detail::one_component_is<alphabet_tuple_base, derived_type, detail::implicitly_convertible_from, indirect_component_type> &&
364 detail::one_component_is<alphabet_tuple_base, derived_type, detail::constructible_from, indirect_component_type>
365 constexpr
explicit alphabet_tuple_base(indirect_component_type
const alph) noexcept : alphabet_tuple_base{}
367 using component_type = meta::front<meta::find_if<component_list, detail::constructible_from<indirect_component_type>>>;
368 component_type tmp(alph);
369 get<component_type>(*this) = tmp;
382 template <
typename component_type>
384 requires is_unique_component<component_type>
386 constexpr derived_type &
operator=(component_type
const alph) noexcept
388 get<component_type>(*this) = alph;
389 return static_cast<derived_type &
>(*this);
401 template <
typename indirect_component_type>
403 requires detail::one_component_is<alphabet_tuple_base, derived_type, detail::assignable_from, indirect_component_type>
405 constexpr derived_type &
operator=(indirect_component_type
const alph) noexcept
407 using component_type = meta::front<meta::find_if<component_list, detail::assignable_from<indirect_component_type>>>;
408 get<component_type>(*this) = alph;
409 return static_cast<derived_type &
>(*this);
413 template <
typename indirect_component_type>
415 requires !detail::one_component_is<alphabet_tuple_base, derived_type, detail::assignable_from, indirect_component_type> &&
416 detail::one_component_is<alphabet_tuple_base, derived_type, detail::implicitly_convertible_from, indirect_component_type>
418 constexpr derived_type & operator=(indirect_component_type
const alph) noexcept
420 using component_type = meta::front<meta::find_if<component_list, detail::implicitly_convertible_from<indirect_component_type>>>;
421 component_type tmp(alph);
422 get<component_type>(*this) = tmp;
423 return static_cast<derived_type &
>(*this);
436 template <
size_t index>
439 static_assert(index <
sizeof...(component_types),
"Index out of range.");
441 using t = meta::at_c<component_list, index>;
447 return component_proxy<t, index>{val, l};
454 template <
typename type>
457 requires is_unique_component<type>
460 return get<meta::find_index<component_list, type>::value>(l);
467 template <
size_t index>
470 static_assert(index <
sizeof...(component_types),
"Index out of range.");
472 using t = meta::at_c<component_list, index>;
485 template <
typename type>
488 requires is_unique_component<type>
491 return get<meta::find_index<component_list, type>::value>(l);
496 template <
typename type>
497 constexpr
operator type() const noexcept
499 requires is_unique_component<type>
502 return get<type>(*this);
511 template <
typename indirect_component_type>
512 constexpr
bool operator==(indirect_component_type
const rhs)
const noexcept
514 requires detail::one_component_is<alphabet_tuple_base, derived_type, detail::weakly_equality_comparable_with, indirect_component_type>
517 using component_type = meta::front<meta::find_if<component_list, detail::weakly_equality_comparable_with<indirect_component_type>>>;
518 return get<component_type>(*this) == rhs;
521 template <
typename indirect_component_type>
522 constexpr
bool operator!=(indirect_component_type
const rhs)
const noexcept
524 requires detail::one_component_is<alphabet_tuple_base, derived_type, detail::weakly_equality_comparable_with, indirect_component_type>
527 using component_type = meta::front<meta::find_if<component_list, detail::weakly_equality_comparable_with<indirect_component_type>>>;
528 return get<component_type>(*this) != rhs;
531 template <
typename indirect_component_type>
532 constexpr
bool operator<(indirect_component_type
const rhs)
const noexcept
534 requires detail::one_component_is<alphabet_tuple_base, derived_type, detail::weakly_ordered_with, indirect_component_type>
537 using component_type = meta::front<meta::find_if<component_list, detail::weakly_ordered_with<indirect_component_type>>>;
538 return get<component_type>(*this) < rhs;
541 template <
typename indirect_component_type>
542 constexpr
bool operator>(indirect_component_type
const rhs)
const noexcept
544 requires detail::one_component_is<alphabet_tuple_base, derived_type, detail::weakly_ordered_with, indirect_component_type>
547 using component_type = meta::front<meta::find_if<component_list, detail::weakly_ordered_with<indirect_component_type>>>;
548 return get<component_type>(*this) > rhs;
551 template <
typename indirect_component_type>
552 constexpr
bool operator<=(indirect_component_type
const rhs)
const noexcept
554 requires detail::one_component_is<alphabet_tuple_base, derived_type, detail::weakly_ordered_with, indirect_component_type>
557 using component_type = meta::front<meta::find_if<component_list, detail::weakly_ordered_with<indirect_component_type>>>;
558 return get<component_type>(*this) <= rhs;
561 template <
typename indirect_component_type>
562 constexpr
bool operator>=(indirect_component_type
const rhs)
const noexcept
564 requires detail::one_component_is<alphabet_tuple_base, derived_type, detail::weakly_ordered_with, indirect_component_type>
567 using component_type = meta::front<meta::find_if<component_list, detail::weakly_ordered_with<indirect_component_type>>>;
568 return get<component_type>(*this) >= rhs;
574 template <
size_t index>
575 constexpr rank_type to_component_rank() const noexcept
577 return (
to_rank() / cummulative_alph_sizes[index]) % seqan3::alphabet_size<meta::at_c<component_list, index>>;
589 meta::for_each(meta::reverse<component_list>{}, [&] (
auto alph) constexpr
591 ret[
count] =
static_cast<rank_type
>(seqan3::alphabet_size<decltype(alph)> * ret[
count - 1]);
611 return ((
to_rank(components) * cummulative_alph_sizes[idx]) + ...);
620 template <
typename indirect_component_type,
typename derived_type,
typename ...component_types>
622 requires detail::WeaklyEqualityComparableByMembersWith<derived_type, indirect_component_type> &&
623 !detail::WeaklyEqualityComparableByMembersWith<indirect_component_type, derived_type>
625 constexpr
bool operator==(indirect_component_type
const lhs,
626 alphabet_tuple_base<derived_type, component_types...>
const rhs) noexcept
631 template <
typename indirect_component_type,
typename derived_type,
typename ...indirect_component_types>
633 requires detail::WeaklyEqualityComparableByMembersWith<derived_type, indirect_component_type> &&
634 !detail::WeaklyEqualityComparableByMembersWith<indirect_component_type, derived_type>
636 constexpr
bool operator!=(indirect_component_type
const lhs,
637 alphabet_tuple_base<derived_type, indirect_component_types...>
const rhs) noexcept
642 template <
typename indirect_component_type,
typename derived_type,
typename ...indirect_component_types>
644 requires detail::WeaklyOrderedByMembersWith<derived_type, indirect_component_type> &&
645 !detail::WeaklyOrderedByMembersWith<indirect_component_type, derived_type>
647 constexpr
bool operator<(indirect_component_type
const lhs,
648 alphabet_tuple_base<derived_type, indirect_component_types...>
const rhs) noexcept
653 template <
typename indirect_component_type,
typename derived_type,
typename ...indirect_component_types>
655 requires detail::WeaklyOrderedByMembersWith<derived_type, indirect_component_type> &&
656 !detail::WeaklyOrderedByMembersWith<indirect_component_type, derived_type>
658 constexpr
bool operator>(indirect_component_type
const lhs,
659 alphabet_tuple_base<derived_type, indirect_component_types...>
const rhs) noexcept
664 template <
typename indirect_component_type,
typename derived_type,
typename ...indirect_component_types>
666 requires detail::WeaklyOrderedByMembersWith<derived_type, indirect_component_type> &&
667 !detail::WeaklyOrderedByMembersWith<indirect_component_type, derived_type>
669 constexpr
bool operator<=(indirect_component_type
const lhs,
670 alphabet_tuple_base<derived_type, indirect_component_types...>
const rhs) noexcept
675 template <
typename indirect_component_type,
typename derived_type,
typename ...indirect_component_types>
677 requires detail::WeaklyOrderedByMembersWith<derived_type, indirect_component_type> &&
678 !detail::WeaklyOrderedByMembersWith<indirect_component_type, derived_type>
680 constexpr
bool operator>=(indirect_component_type
const lhs,
681 alphabet_tuple_base<derived_type, indirect_component_types...>
const rhs) noexcept
697 template <std::
size_t i, seqan3::detail::AlphabetTupleBase tuple_t>
698 struct tuple_element<i, tuple_t>
701 using type = meta::at_c<typename tuple_t::seqan3_tuple_components, i>;
709 template <seqan3::detail::AlphabetTupleBase tuple_t>
710 struct tuple_size<tuple_t> :
Provides concepts for core language types and relations that don't have concepts in C++20 (yet)...
constexpr auto assign_rank_to
Assign a rank to an alphabet object.
Definition: concept.hpp:207
A CRTP-base that eases the definition of proxy types returned in place of regular alphabets...
Definition: alphabet_proxy.hpp:131
constexpr derived_type & operator=(component_type const alph) noexcept
Assignment via a value of one of the components.
Definition: alphabet_tuple_base.hpp:386
Provides metaprogramming utilities for integer types.
constexpr alphabet_tuple_base(component_type const alph) noexcept
Construction via a value of one of the components.
Definition: alphabet_tuple_base.hpp:332
Provides unary type traits on a set of types, usually provided as template argument pack...
constexpr auto to_rank
Return the rank representation of a (semi-)alphabet object.
Definition: concept.hpp:103
SeqAn specific customisations in the standard namespace.
constexpr auto const & get(configuration< configs_t... > const &config) noexcept
Definition: configuration.hpp:578
::ranges::size size
Alias for ranges::size. Obtains the size of a range whose size can be calculated in constant time...
Definition: ranges:189
The main SeqAn3 namespace.
Provides implementation detail for seqan3::alphabet_variant and seqan3::alphabet_tuple_base.
constexpr derived_type & assign_rank(rank_type const c) noexcept
Assign from a numeric value.
Definition: alphabet_base.hpp:166
Provides seqan3::TupleLike.
The CRTP base for a combined alphabet that contains multiple values of different alphabets at the sam...
Definition: alphabet_tuple_base.hpp:188
constexpr alphabet_tuple_base(indirect_component_type const alph) noexcept
Construction via a value of a subtype that is assignable to one of the components.
Definition: alphabet_tuple_base.hpp:354
Free function/type trait wrappers for alphabets with member functions/types.
Provides utility functions for tuple like interfaces.
Provides seqan3::alphabet_base.
constexpr derived_type & operator=(indirect_component_type const alph) noexcept
Assignment via a value of a subtype that is assignable to one of the components.
Definition: alphabet_tuple_base.hpp:405
Definition: aligned_sequence_concept.hpp:35
meta::at_c< typename tuple_t::seqan3_tuple_components, i > type
Element type.
Definition: alphabet_tuple_base.hpp:701
constexpr rank_type to_rank() const noexcept
Return the letter's numeric value (rank in the alphabet).
Definition: alphabet_base.hpp:117
::ranges::empty empty
Alias for ranges::empty. Checks whether a range is empty.
Definition: ranges:194
Core alphabet concept and free function/type trait wrappers.
A CRTP-base that makes defining a custom alphabet easier.
Definition: alphabet_base.hpp:52
Quality alphabet concept.
constexpr auto alphabet_size
A type trait that holds the size of a (semi-)alphabet.
Definition: concept.hpp:678