The CRTP base for a combined alphabet that contains multiple values of different alphabets at the same time.. More...
#include <bio/alphabet/composite/tuple_base.hpp>
Public Member Functions | |
Read functions | |
constexpr char_type | to_char () const noexcept |
Return the letter as a character of char_type. | |
constexpr rank_type | to_rank () const noexcept |
Return the letter's numeric value (rank in the alphabet). | |
Write functions | |
constexpr derived_type & | assign_char (char_type const c) noexcept |
Assign from a character, implicitly converts invalid characters. | |
constexpr derived_type & | assign_rank (rank_type const c) noexcept |
Assign from a numeric value. | |
Static Public Attributes | |
static constexpr size_t | 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. | |
using | rank_type = meta::detail::min_viable_uint_t< size - 1 > |
The type of the alphabet when represented as a number (e.g. via to_rank()). | |
Friends | |
Comparison operators (against indirect component_list) | |
These overloads enable comparison for all types that a component type is comparable with. | |
template<std::same_as< derived_type > derived_type_t, typename indirect_component_type > requires (detail::tuple_concept_guard<derived_type, indirect_component_type, component_types...> && (meta::weakly_equality_comparable_with<indirect_component_type, component_types> || ...)) | |
constexpr bool | operator== (derived_type_t const lhs, indirect_component_type const rhs) noexcept |
Comparison against types comparable with components. | |
template<std::same_as< derived_type > derived_type_t, typename indirect_component_type > requires (detail::tuple_concept_guard<derived_type, indirect_component_type, component_types...> && (meta::weakly_ordered_with<indirect_component_type, component_types> || ...)) | |
constexpr auto | operator<=> (derived_type_t const lhs, indirect_component_type const rhs) noexcept |
Comparison against types comparable with components. | |
Constructors, destructor and assignment | |
| |
constexpr | tuple_base (component_types... components) noexcept |
Construction from initialiser-list. | |
template<typename component_type > requires ((!std::is_base_of_v<tuple_base, component_type>) && is_unique_component<component_type>) | |
constexpr | tuple_base (component_type const alph) noexcept |
Construction via a value of one of the components. | |
template<typename indirect_component_type > requires (detail::tuple_concept_guard<derived_type, indirect_component_type, component_types...> && (std::is_convertible_v<indirect_component_type, component_types> || ...)) | |
constexpr | tuple_base (indirect_component_type const alph) noexcept |
Construction via a value of a subtype that is assignable to one of the components. | |
template<typename component_type > requires ((!std::derived_from<component_type, tuple_base>) && is_unique_component<component_type>) | |
constexpr derived_type & | operator= (component_type const alph) noexcept |
Assignment via a value of one of the components. | |
template<typename indirect_component_type > requires ((!std::derived_from<indirect_component_type, tuple_base>) && (!is_unique_component<indirect_component_type>) && (std::assignable_from<component_types, 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. | |
Read functions | |
All read operations are constant complexity. | |
template<typename type > requires is_unique_component<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 (tuple_base &l) noexcept |
Tuple-like access to the contained components. | |
template<typename type > requires is_unique_component<type> | |
constexpr auto | get (tuple_base &l) noexcept |
Tuple-like access to the contained components. | |
template<size_t index> | |
constexpr auto | get (tuple_base const &l) noexcept |
Tuple-like access to the contained components. | |
template<typename type > requires is_unique_component<type> | |
constexpr type | get (tuple_base const &l) noexcept |
Tuple-like access to the contained components. | |
The CRTP base for a combined alphabet that contains multiple values of different alphabets at the same time.
.
component_types | Types of letters; must model std::regular and bio::alphabet::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:
|
inlineexplicitconstexprnoexcept |
Construction via a value of one of the components.
component_type | Must be one uniquely contained in the type list of the composite. |
alph | The value of a component that should be assigned. |
Note: Since the tuple_base is a CRTP base class, we show the working examples with one of its derived classes (bio::alphabet::qualified).
|
inlineexplicitconstexprnoexcept |
Construction via a value of a subtype that is assignable to one of the components.
indirect_component_type | Type that models bio::alphabet::weakly_assignable_from for one of the component types. |
alph | The 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 tuple_base is a CRTP base class, we show the working examples with one of its derived classes (bio::alphabet::qualified).
|
inlineconstexprnoexceptinherited |
Assign from a character, implicitly converts invalid characters.
c | The character to be assigned. |
Provides an implementation for bio::alphabet::assign_char_to, required to model bio::alphabet::alphabet.
Constant.
Guaranteed not to throw.
|
inlineconstexprnoexceptinherited |
Assign from a numeric value.
c | The rank to be assigned. |
Provides an implementation for bio::alphabet::assign_rank_to, required to model bio::alphabet::semialphabet.
Constant.
Guaranteed not to throw.
|
inlineconstexprnoexcept |
Implicit cast to a single letter. Works only if the type is unique in the type list.
|
inlineconstexprnoexcept |
Assignment via a value of one of the components.
component_type | One of the component types. Must be uniquely contained in the type list of the composite. |
alph | The value of a component that should be assigned. |
Note: Since the tuple_base is a CRTP base class, we show the working examples with one of its derived classes (bio::alphabet::qualified).
|
inlineconstexprnoexcept |
Assignment via a value of a subtype that is assignable to one of the components.
indirect_component_type | Type that models bio::alphabet::weakly_assignable_from for one of the component types. |
alph | The value of a component that should be assigned. |
Note: Since the tuple_base is a CRTP base class, we show the working examples with one of its derived classes (bio::alphabet::qualified).
|
inlineconstexprnoexceptinherited |
Return the letter as a character of char_type.
Provides an implementation for bio::alphabet::to_char, required to model bio::alphabet::alphabet.
Constant.
Guaranteed not to throw.
|
inlineconstexprnoexceptinherited |
Return the letter's numeric value (rank in the alphabet).
Provides an implementation for bio::alphabet::to_rank, required to model bio::alphabet::semialphabet.
Constant.
Guaranteed not to throw.
|
friend |
Tuple-like access to the contained components.
index | Return the i-th element. |
|
friend |
Tuple-like access to the contained components.
type | Return the element of specified type; only available if the type is unique in the set of components. |
|
friend |
Tuple-like access to the contained components.
index | Return the i-th element. |
|
friend |
Tuple-like access to the contained components.
type | Return the element of specified type; only available if the type is unique in the set of components. |
|
friend |
Comparison against types comparable with components.
indirect_component_type | Must be comparable with a component's type. |
lhs | Left-hand-side of comparison. |
rhs | Right-hand-side of comparison. |
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.
|
friend |
Comparison against types comparable with components.
indirect_component_type | Must be comparable with a component's type. |
lhs | Left-hand-side of comparison. |
rhs | Right-hand-side of comparison. |
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.