SeqAn3  3.0.2
The Modern C++ library for sequence analysis.
seqan3::alphabet_tuple_base< derived_type, component_types > Class Template Reference

The CRTP base for a combined alphabet that contains multiple values of different alphabets at the same time. More...

#include <seqan3/alphabet/composite/alphabet_tuple_base.hpp>

+ Inheritance diagram for seqan3::alphabet_tuple_base< derived_type, component_types >:

Public Member Functions

Read functions
constexpr char_type to_char () const noexcept
 Return the letter as a character of char_type. More...
 
constexpr rank_type to_rank () const noexcept
 Return the letter's numeric value (rank in the alphabet). More...
 
Write functions
constexpr derived_type & assign_char (char_type const c) noexcept
 Assign from a character, implicitly converts invalid characters. More...
 
constexpr derived_type & assign_rank (rank_type const c) noexcept
 Assign from a numeric value. More...
 

Static Public Attributes

static detail::min_viable_uint_t< size > constexpr alphabet_size
 The size of the alphabet, i.e. the number of different values it can take.
 

Protected Types

Member types
using char_type = std::conditional_t< std::same_as< void, void >, char, void >
 The char representation; conditional needed to make semi alphabet definitions legal.
 

Friends

Comparison operators (against indirect component_list)

These overloads enable comparison for all types that a component type is comparable with.

template<typename derived_type_t , typename indirect_component_type >
constexpr auto operator== (derived_type_t const lhs, indirect_component_type const rhs) noexcept -> std::enable_if_t< detail::tuple_eq_guard< derived_type_t, derived_type, indirect_component_type, component_types... >, bool >
 Comparison against types comparable with components. More...
 
template<typename derived_type_t , typename indirect_component_type >
constexpr auto operator== (indirect_component_type const lhs, derived_type_t const rhs) noexcept -> std::enable_if_t< detail::tuple_eq_guard< derived_type_t, derived_type, indirect_component_type, component_types... >, bool >
 Comparison against types comparable with components. More...
 
template<typename derived_type_t , typename indirect_component_type >
constexpr auto operator!= (derived_type_t const lhs, indirect_component_type const rhs) noexcept -> std::enable_if_t< detail::tuple_eq_guard< derived_type_t, derived_type, indirect_component_type, component_types... >, bool >
 Comparison against types comparable with components. More...
 
template<typename derived_type_t , typename indirect_component_type >
constexpr auto operator!= (indirect_component_type const lhs, derived_type_t const rhs) noexcept -> std::enable_if_t< detail::tuple_eq_guard< derived_type_t, derived_type, indirect_component_type, component_types... >, bool >
 Comparison against types comparable with components. More...
 
template<typename derived_type_t , typename indirect_component_type >
constexpr auto operator< (derived_type_t const lhs, indirect_component_type const rhs) noexcept -> std::enable_if_t< detail::tuple_order_guard< derived_type_t, derived_type, indirect_component_type, component_types... >, bool >
 Comparison against types comparable with components. More...
 
template<typename derived_type_t , typename indirect_component_type >
constexpr auto operator< (indirect_component_type const lhs, derived_type_t const rhs) noexcept -> std::enable_if_t< detail::tuple_order_guard< derived_type_t, derived_type, indirect_component_type, component_types... >, bool >
 Comparison against types comparable with components. More...
 
template<typename derived_type_t , typename indirect_component_type >
constexpr auto operator<= (derived_type_t const lhs, indirect_component_type const rhs) noexcept -> std::enable_if_t< detail::tuple_order_guard< derived_type_t, derived_type, indirect_component_type, component_types... >, bool >
 Comparison against types comparable with components. More...
 
template<typename derived_type_t , typename indirect_component_type >
constexpr auto operator<= (indirect_component_type const lhs, derived_type_t const rhs) noexcept -> std::enable_if_t< detail::tuple_order_guard< derived_type_t, derived_type, indirect_component_type, component_types... >, bool >
 Comparison against types comparable with components. More...
 
template<typename derived_type_t , typename indirect_component_type >
constexpr auto operator> (derived_type_t const lhs, indirect_component_type const rhs) noexcept -> std::enable_if_t< detail::tuple_order_guard< derived_type_t, derived_type, indirect_component_type, component_types... >, bool >
 Comparison against types comparable with components. More...
 
template<typename derived_type_t , typename indirect_component_type >
constexpr auto operator> (indirect_component_type const lhs, derived_type_t const rhs) noexcept -> std::enable_if_t< detail::tuple_order_guard< derived_type_t, derived_type, indirect_component_type, component_types... >, bool >
 Comparison against types comparable with components. More...
 
template<typename derived_type_t , typename indirect_component_type >
constexpr auto operator>= (derived_type_t const lhs, indirect_component_type const rhs) noexcept -> std::enable_if_t< detail::tuple_order_guard< derived_type_t, derived_type, indirect_component_type, component_types... >, bool >
 Comparison against types comparable with components. More...
 
template<typename derived_type_t , typename indirect_component_type >
constexpr auto operator>= (indirect_component_type const lhs, derived_type_t const rhs) noexcept -> std::enable_if_t< detail::tuple_order_guard< derived_type_t, derived_type, indirect_component_type, component_types... >, bool >
 Comparison against types comparable with components. More...
 

Related Functions

(Note that these are not member functions.)

Requirements for std::totally_ordered

You can expect these functions on all types that implement std::totally_ordered.

bool operator< (type const &lhs, type const &rhs)
 Less-than, greater-than and -or-equal comparisons. More...
 
bool operator<= (type const &lhs, type const &rhs)
 Less-than, greater-than and -or-equal comparisons. More...
 
bool operator> (type const &lhs, type const &rhs)
 Less-than, greater-than and -or-equal comparisons. More...
 
bool operator>= (type const &lhs, type const &rhs)
 Less-than, greater-than and -or-equal comparisons. More...
 
Requirements for std::equality_comparable

You can expect these functions on all types that implement std::Equality_comparable.

bool operator== (type const &lhs, type const &rhs)
 (In-)Equality comparison. More...
 
bool operator!= (type const &lhs, type const &rhs)
 (In-)Equality comparison. More...
 

Constructors, destructor and assignment

Attention
Please do not directly use the CRTP base class. The functions are only public for the usage in their derived classes (e.g. seqan3::qualified, seqan3::masked, seqan3::structure_rna and seqan3::structure_aa).
constexpr alphabet_tuple_base (component_types ... components) noexcept
 Construction from initialiser-list.
 
template<typename component_type >
constexpr alphabet_tuple_base (component_type const alph) noexcept
 Construction via a value of one of the components. More...
 
template<typename indirect_component_type >
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. More...
 
template<typename component_type >
constexpr derived_type & operator= (component_type const alph) noexcept
 Assignment via a value of one of the components. More...
 
template<typename indirect_component_type >
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. More...
 

Read functions

All read operations are constant complexity.

template<typename type >
constexpr operator type () const noexcept
 Implicit cast to a single letter. Works only if the type is unique in the type list.
 
template<size_t index>
constexpr auto get (alphabet_tuple_base &l) noexcept
 Tuple-like access to the contained components. More...
 
template<typename type >
constexpr auto get (alphabet_tuple_base &l) noexcept
 Tuple-like access to the contained components. More...
 
template<size_t index>
constexpr auto get (alphabet_tuple_base const &l) noexcept
 Tuple-like access to the contained components. More...
 
template<typename type >
constexpr type get (alphabet_tuple_base const &l) noexcept
 Tuple-like access to the contained components. More...
 

Detailed Description

template<typename derived_type, typename ... component_types>
class seqan3::alphabet_tuple_base< derived_type, component_types >

The CRTP base for a combined alphabet that contains multiple values of different alphabets at the same time.

Template Parameters
component_typesTypes of letters; must model std::regular and seqan3::writable_semialphabet and all required function calls need to be callable in constexpr-context.

This data structure is a CRTP base class for combined alphabets, where the different alphabet letters exist independently as a components, similar to a tuple.

Short description:

  • combines multiple alphabets as independent components, similar to a tuple;
  • models seqan3::tuple_like, i.e. provides a get interface to its component_list;
  • is itself a seqan3::writable_semialphabet, but most derived types implement the full seqan3::writable_alphabet;
  • its alphabet size is the product of the individual sizes;
  • constructible, assignable and comparable with each component type and also all types that these are constructible/assignable/comparable with;
  • explicitly convertible to each of its component types
Attention
This is a "pure base class", you cannot instantiate it, you can only inherit from it. Most likely you are interested in using one of it's descendants like seqan3::qualified or seqan3::masked.
See also
qualified
masked

Constructor & Destructor Documentation

◆ alphabet_tuple_base() [1/2]

template<typename derived_type, typename ... component_types>
template<typename component_type >
constexpr seqan3::alphabet_tuple_base< derived_type, component_types >::alphabet_tuple_base ( component_type const  alph)
inlineexplicitnoexcept

Construction via a value of one of the components.

Template Parameters
component_typeMust be one uniquely contained in the type list of the composite.
Parameters
alphThe value of a component that should be assigned.

Note: Since the alphabet_tuple_base is a CRTP base class, we show the working examples with one of its derived classes (seqan3::qualified).

int main()
{
using seqan3::operator""_dna4;
// creates {'C'_dna4, seqan3::phred42{0}}
// creates {'A'_dna4, seqan3::phred42{1}}
if (letter1 == letter2)
seqan3::debug_stream << "yeah\n"; // yeah
}

◆ alphabet_tuple_base() [2/2]

template<typename derived_type, typename ... component_types>
template<typename indirect_component_type >
constexpr seqan3::alphabet_tuple_base< derived_type, component_types >::alphabet_tuple_base ( indirect_component_type const  alph)
inlineexplicitnoexcept

Construction via a value of a subtype that is assignable to one of the components.

Template Parameters
indirect_component_typeType that models seqan3::weakly_assignable_from for one of the component types.
Parameters
alphThe value that should be assigned.

Note that the value will be assigned to the FIRST type T that fulfils assignable_from<T, indirect_component_type>, regardless if other types are also fit for assignment.

Note: Since the alphabet_tuple_base is a CRTP base class, we show the working examples with one of its derived classes (seqan3::qualified).

int main()
{
using seqan3::operator""_dna4;
using seqan3::operator""_rna4;
// The following creates {'C'_dna4, phred42{0}}
// The following also creates {'C'_dna4, seqan3::phred42{0}}, since rna4 assignable to dna4
if (letter1 == letter2)
seqan3::debug_stream << "yeah\n"; // yeah
}

Member Function Documentation

◆ assign_char()

constexpr derived_type& seqan3::alphabet_base< derived_type, size, void >::assign_char ( char_type const  c)
inlinenoexceptinherited

Assign from a character, implicitly converts invalid characters.

Parameters
cThe character to be assigned.

Provides an implementation for seqan3::assign_char_to, required to model seqan3::alphabet.

Complexity

Constant.

Exceptions

Guaranteed not to throw.

◆ assign_rank()

constexpr derived_type& seqan3::alphabet_base< derived_type, size, void >::assign_rank ( rank_type const  c)
inlinenoexceptinherited

Assign from a numeric value.

Parameters
cThe rank to be assigned.

Provides an implementation for seqan3::assign_rank_to, required to model seqan3::semialphabet.

Complexity

Constant.

Exceptions

Guaranteed not to throw.

◆ operator=() [1/2]

template<typename derived_type, typename ... component_types>
template<typename component_type >
constexpr derived_type& seqan3::alphabet_tuple_base< derived_type, component_types >::operator= ( component_type const  alph)
inlinenoexcept

Assignment via a value of one of the components.

Template Parameters
component_typeOne of the component types. Must be uniquely contained in the type list of the composite.
Parameters
alphThe value of a component that should be assigned.

Note: Since the alphabet_tuple_base is a CRTP base class, we show the working examples with one of its derived classes (seqan3::qualified).

int main()
{
using seqan3::operator""_dna4;
letter1 = 'C'_dna4; // yields {'C'_dna4, seqan3::phred42{1}}
letter1 = seqan3::phred42{2}; // yields {'C'_dna4, seqan3::phred42{2}}
}

◆ operator=() [2/2]

template<typename derived_type, typename ... component_types>
template<typename indirect_component_type >
constexpr derived_type& seqan3::alphabet_tuple_base< derived_type, component_types >::operator= ( indirect_component_type const  alph)
inlinenoexcept

Assignment via a value of a subtype that is assignable to one of the components.

Template Parameters
indirect_component_typeType that models seqan3::weakly_assignable_from for one of the component types.
Parameters
alphThe value of a component that should be assigned.

Note: Since the alphabet_tuple_base is a CRTP base class, we show the working examples with one of its derived classes (seqan3::qualified).

int main()
{
using seqan3::operator""_dna4;
using seqan3::operator""_rna4;
letter1 = 'C'_rna4; // yields {'C'_dna4, seqan3::phred42{1}}
}

◆ to_char()

constexpr char_type seqan3::alphabet_base< derived_type, size, void >::to_char ( ) const
inlinenoexceptinherited

Return the letter as a character of char_type.

Provides an implementation for seqan3::to_char, required to model seqan3::alphabet.

Complexity

Constant.

Exceptions

Guaranteed not to throw.

◆ to_rank()

constexpr rank_type seqan3::alphabet_base< derived_type, size, void >::to_rank ( ) const
inlinenoexceptinherited

Return the letter's numeric value (rank in the alphabet).

Provides an implementation for seqan3::to_rank, required to model seqan3::semialphabet.

Complexity

Constant.

Exceptions

Guaranteed not to throw.

Friends And Related Function Documentation

◆ get [1/4]

template<typename derived_type, typename ... component_types>
template<size_t index>
constexpr auto get ( alphabet_tuple_base< derived_type, component_types > &  l)
friend

Tuple-like access to the contained components.

Template Parameters
indexReturn the i-th element.
Returns
A proxy to the contained element that models the same alphabets concepts and supports assignment.

◆ get [2/4]

template<typename derived_type, typename ... component_types>
template<typename type >
constexpr auto get ( alphabet_tuple_base< derived_type, component_types > &  l)
friend

Tuple-like access to the contained components.

Template Parameters
typeReturn the element of specified type; only available if the type is unique in the set of components.
Returns
A proxy to the contained element that models the same alphabets concepts and supports assignment.

◆ get [3/4]

template<typename derived_type, typename ... component_types>
template<size_t index>
constexpr auto get ( alphabet_tuple_base< derived_type, component_types > const &  l)
friend

Tuple-like access to the contained components.

Template Parameters
indexReturn the i-th element.
Returns
A copy of the contained element.

◆ get [4/4]

template<typename derived_type, typename ... component_types>
template<typename type >
constexpr type get ( alphabet_tuple_base< derived_type, component_types > const &  l)
friend

Tuple-like access to the contained components.

Template Parameters
typeReturn the element of specified type; only available if the type is unique in the set of components.
Returns
A copy of the contained element.

◆ operator!= [1/2]

template<typename derived_type, typename ... component_types>
template<typename derived_type_t , typename indirect_component_type >
constexpr auto operator!= ( derived_type_t const  lhs,
indirect_component_type const  rhs 
) -> std::enable_if_t<detail::tuple_eq_guard<derived_type_t, derived_type, indirect_component_type, component_types...>, bool>
friend

Comparison against types comparable with components.

Template Parameters
indirect_component_typeMust be comparable with a component's type.
Parameters
lhsLeft-hand-side of comparison.
rhsRight-hand-side of comparison.
Returns
true or false.

To determine (in-)equality/order, it is first deduced which component the argument is comparable with. The tuple is then cast to that type and the resulting value compared with the argument.

◆ operator!= [2/2]

template<typename derived_type, typename ... component_types>
template<typename derived_type_t , typename indirect_component_type >
constexpr auto operator!= ( indirect_component_type const  lhs,
derived_type_t const  rhs 
) -> std::enable_if_t<detail::tuple_eq_guard<derived_type_t, derived_type, indirect_component_type, component_types...>, bool>
friend

Comparison against types comparable with components.

Template Parameters
indirect_component_typeMust be comparable with a component's type.
Parameters
lhsLeft-hand-side of comparison.
rhsRight-hand-side of comparison.
Returns
true or false.

To determine (in-)equality/order, it is first deduced which component the argument is comparable with. The tuple is then cast to that type and the resulting value compared with the argument.

◆ operator< [1/2]

template<typename derived_type, typename ... component_types>
template<typename derived_type_t , typename indirect_component_type >
constexpr auto operator< ( derived_type_t const  lhs,
indirect_component_type const  rhs 
) -> std::enable_if_t<detail::tuple_order_guard<derived_type_t, derived_type, indirect_component_type, component_types...>, bool>
friend

Comparison against types comparable with components.

Template Parameters
indirect_component_typeMust be comparable with a component's type.
Parameters
lhsLeft-hand-side of comparison.
rhsRight-hand-side of comparison.
Returns
true or false.

To determine (in-)equality/order, it is first deduced which component the argument is comparable with. The tuple is then cast to that type and the resulting value compared with the argument.

◆ operator< [2/2]

template<typename derived_type, typename ... component_types>
template<typename derived_type_t , typename indirect_component_type >
constexpr auto operator< ( indirect_component_type const  lhs,
derived_type_t const  rhs 
) -> std::enable_if_t<detail::tuple_order_guard<derived_type_t, derived_type, indirect_component_type, component_types...>, bool>
friend

Comparison against types comparable with components.

Template Parameters
indirect_component_typeMust be comparable with a component's type.
Parameters
lhsLeft-hand-side of comparison.
rhsRight-hand-side of comparison.
Returns
true or false.

To determine (in-)equality/order, it is first deduced which component the argument is comparable with. The tuple is then cast to that type and the resulting value compared with the argument.

◆ operator<= [1/2]

template<typename derived_type, typename ... component_types>
template<typename derived_type_t , typename indirect_component_type >
constexpr auto operator<= ( derived_type_t const  lhs,
indirect_component_type const  rhs 
) -> std::enable_if_t<detail::tuple_order_guard<derived_type_t, derived_type, indirect_component_type, component_types...>, bool>
friend

Comparison against types comparable with components.

Template Parameters
indirect_component_typeMust be comparable with a component's type.
Parameters
lhsLeft-hand-side of comparison.
rhsRight-hand-side of comparison.
Returns
true or false.

To determine (in-)equality/order, it is first deduced which component the argument is comparable with. The tuple is then cast to that type and the resulting value compared with the argument.

◆ operator<= [2/2]

template<typename derived_type, typename ... component_types>
template<typename derived_type_t , typename indirect_component_type >
constexpr auto operator<= ( indirect_component_type const  lhs,
derived_type_t const  rhs 
) -> std::enable_if_t<detail::tuple_order_guard<derived_type_t, derived_type, indirect_component_type, component_types...>, bool>
friend

Comparison against types comparable with components.

Template Parameters
indirect_component_typeMust be comparable with a component's type.
Parameters
lhsLeft-hand-side of comparison.
rhsRight-hand-side of comparison.
Returns
true or false.

To determine (in-)equality/order, it is first deduced which component the argument is comparable with. The tuple is then cast to that type and the resulting value compared with the argument.

◆ operator== [1/2]

template<typename derived_type, typename ... component_types>
template<typename derived_type_t , typename indirect_component_type >
constexpr auto operator== ( derived_type_t const  lhs,
indirect_component_type const  rhs 
) -> std::enable_if_t<detail::tuple_eq_guard<derived_type_t, derived_type, indirect_component_type, component_types...>, bool>
friend

Comparison against types comparable with components.

Template Parameters
indirect_component_typeMust be comparable with a component's type.
Parameters
lhsLeft-hand-side of comparison.
rhsRight-hand-side of comparison.
Returns
true or false.

To determine (in-)equality/order, it is first deduced which component the argument is comparable with. The tuple is then cast to that type and the resulting value compared with the argument.

◆ operator== [2/2]

template<typename derived_type, typename ... component_types>
template<typename derived_type_t , typename indirect_component_type >
constexpr auto operator== ( indirect_component_type const  lhs,
derived_type_t const  rhs 
) -> std::enable_if_t<detail::tuple_eq_guard<derived_type_t, derived_type, indirect_component_type, component_types...>, bool>
friend

Comparison against types comparable with components.

Template Parameters
indirect_component_typeMust be comparable with a component's type.
Parameters
lhsLeft-hand-side of comparison.
rhsRight-hand-side of comparison.
Returns
true or false.

To determine (in-)equality/order, it is first deduced which component the argument is comparable with. The tuple is then cast to that type and the resulting value compared with the argument.

◆ operator> [1/2]

template<typename derived_type, typename ... component_types>
template<typename derived_type_t , typename indirect_component_type >
constexpr auto operator> ( derived_type_t const  lhs,
indirect_component_type const  rhs 
) -> std::enable_if_t<detail::tuple_order_guard<derived_type_t, derived_type, indirect_component_type, component_types...>, bool>
friend

Comparison against types comparable with components.

Template Parameters
indirect_component_typeMust be comparable with a component's type.
Parameters
lhsLeft-hand-side of comparison.
rhsRight-hand-side of comparison.
Returns
true or false.

To determine (in-)equality/order, it is first deduced which component the argument is comparable with. The tuple is then cast to that type and the resulting value compared with the argument.

◆ operator> [2/2]

template<typename derived_type, typename ... component_types>
template<typename derived_type_t , typename indirect_component_type >
constexpr auto operator> ( indirect_component_type const  lhs,
derived_type_t const  rhs 
) -> std::enable_if_t<detail::tuple_order_guard<derived_type_t, derived_type, indirect_component_type, component_types...>, bool>
friend

Comparison against types comparable with components.

Template Parameters
indirect_component_typeMust be comparable with a component's type.
Parameters
lhsLeft-hand-side of comparison.
rhsRight-hand-side of comparison.
Returns
true or false.

To determine (in-)equality/order, it is first deduced which component the argument is comparable with. The tuple is then cast to that type and the resulting value compared with the argument.

◆ operator>= [1/2]

template<typename derived_type, typename ... component_types>
template<typename derived_type_t , typename indirect_component_type >
constexpr auto operator>= ( derived_type_t const  lhs,
indirect_component_type const  rhs 
) -> std::enable_if_t<detail::tuple_order_guard<derived_type_t, derived_type, indirect_component_type, component_types...>, bool>
friend

Comparison against types comparable with components.

Template Parameters
indirect_component_typeMust be comparable with a component's type.
Parameters
lhsLeft-hand-side of comparison.
rhsRight-hand-side of comparison.
Returns
true or false.

To determine (in-)equality/order, it is first deduced which component the argument is comparable with. The tuple is then cast to that type and the resulting value compared with the argument.

◆ operator>= [2/2]

template<typename derived_type, typename ... component_types>
template<typename derived_type_t , typename indirect_component_type >
constexpr auto operator>= ( indirect_component_type const  lhs,
derived_type_t const  rhs 
) -> std::enable_if_t<detail::tuple_order_guard<derived_type_t, derived_type, indirect_component_type, component_types...>, bool>
friend

Comparison against types comparable with components.

Template Parameters
indirect_component_typeMust be comparable with a component's type.
Parameters
lhsLeft-hand-side of comparison.
rhsRight-hand-side of comparison.
Returns
true or false.

To determine (in-)equality/order, it is first deduced which component the argument is comparable with. The tuple is then cast to that type and the resulting value compared with the argument.


The documentation for this class was generated from the following file: