A combined alphabet that can hold values of either of its alternatives. More...
#include <seqan3/alphabet/composition/union_composition.hpp>
Public Types | |
using | char_type = char_t |
The type of the alphabet when converted to char (e.g. via to_char()). | |
using | rank_type = detail::min_viable_uint_t< size - 1 > |
The type of the alphabet when represented as a number (e.g. via to_rank()). | |
Public Member Functions | |
Constructors, destructor and assignment | |
constexpr | union_composition ()=default |
constexpr | union_composition (union_composition const &)=default |
constexpr | union_composition (union_composition &&)=default |
constexpr union_composition & | operator= (union_composition const &)=default |
constexpr union_composition & | operator= (union_composition &&)=default |
~union_composition ()=default | |
template<typename alternative_t > | |
constexpr | union_composition (alternative_t const &alternative) noexcept |
Construction via the value of an alternative. More... | |
template<typename indirect_alternative_t > | |
constexpr | union_composition (indirect_alternative_t const &rhs) noexcept |
Construction via the value of a type that an alternative type is constructible from. More... | |
template<typename indirect_alternative_t > | |
constexpr union_composition & | operator= (indirect_alternative_t const &rhs) noexcept |
Assignment via a value that one of the alternative types is assignable from. More... | |
Conversion (by index) | |
template<size_t index> | |
constexpr bool | is_alternative () const noexcept |
Whether the union alphabet currently holds a value of the given alternative. More... | |
template<size_t index> | |
constexpr auto | convert_to () const |
Convert to the specified alphabet (throws if is_alternative() would be false). More... | |
template<size_t index> | |
constexpr auto | convert_unsafely_to () const noexcept |
Convert to the specified alphabet (undefined behaviour if is_alternative() would be false). More... | |
Conversion (by type) | |
template<typename alternative_t > | |
constexpr bool | is_alternative () const noexcept requires holds_alternative< alternative_t >() |
Whether the union alphabet currently holds a value of the given alternative. More... | |
template<typename alternative_t > | |
constexpr alternative_t | convert_to () const requires holds_alternative< alternative_t >() |
Convert to the specified alphabet (throws if is_alternative() would be false). More... | |
template<typename alternative_t > | |
constexpr alternative_t | convert_unsafely_to () const noexcept requires holds_alternative< alternative_t >() |
Convert to the specified alphabet (undefined behaviour if is_alternative() would be false). More... | |
Comparison operators (against alternatives) | |
template<typename alternative_t > | |
constexpr bool | operator== (alternative_t const &rhs) const noexcept requires holds_alternative< alternative_t >() |
template<typename alternative_t > | |
constexpr bool | operator!= (alternative_t const &rhs) const noexcept requires holds_alternative< alternative_t >() |
Comparison operators (against indirect alternatives) | |
template<typename indirect_alternative_type > | |
constexpr bool | operator== (indirect_alternative_type const &rhs) const noexcept |
template<typename indirect_alternative_type > | |
constexpr bool | operator!= (indirect_alternative_type const &rhs) const noexcept |
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 union_composition< alternative_types... > & | assign_char (std::conditional_t< std::Same< char_type, void >, char, char_type > const c) noexcept |
Assign from a character. More... | |
constexpr union_composition< alternative_types... > & | assign_rank (rank_type const c) noexcept |
Assign from a numeric value. More... | |
Static Public Member Functions | |
template<typename alternative_t > | |
static constexpr bool | holds_alternative () noexcept |
Returns true if alternative_t is one of the given alternative types. More... | |
Static Public Attributes | |
static detail::min_viable_uint_t< size > constexpr | value_size |
The size of the alphabet, i.e. the number of different values it can take. | |
Related Functions | |
(Note that these are not member functions.) | |
Comparison operators | |
Free function (in-)equality comparison operators that forward to member operators (for types != self). | |
template<typename lhs_t , typename ... alternative_types> | |
constexpr bool | operator== (lhs_t const &lhs, union_composition< alternative_types... > const &rhs) noexcept |
template<typename lhs_t , typename ... alternative_types> | |
constexpr bool | operator!= (lhs_t const &lhs, union_composition< alternative_types... > const &rhs) noexcept |
Requirements for seqan3::alphabet_concept | |
You can expect these functions on all types that implement seqan3::alphabet_concept. | |
template<typename alphabet_type > | |
using | underlying_char_t = typename underlying_char< alphabet_type >::type |
The char_type of the alphabet. [type metafunction shortcut]. More... | |
char_type | to_char (alphabet_concept const alph) |
Returns the alphabet letter's value in character representation. More... | |
alphabet_concept && | assign_char (alphabet_concept &&alph, char_type const chr) |
Returns the alphabet letter's value in character representation. More... | |
Requirements for seqan3::semi_alphabet_concept | |
You can expect these functions on all types that implement seqan3::semi_alphabet_concept. | |
template<typename semi_alphabet_type > | |
using | underlying_rank_t = typename underlying_rank< semi_alphabet_type >::type |
The rank_type of the semi_alphabet. [type metafunction shortcut]. More... | |
template<typename alphabet_type > | |
constexpr auto | alphabet_size_v = alphabet_size<alphabet_type>::value |
The size of the alphabet. [value metafunction shortcut]. More... | |
rank_type | to_rank (semi_alphabet_concept const alph) |
Returns the alphabet letter's value in rank representation. More... | |
semi_alphabet_concept && | assign_rank (semi_alphabet_concept &&alph, rank_type const rank) |
Returns the alphabet letter's value in rank representation. More... | |
Requirements for std::Swappable | |
You can expect these functions on all types that implement std::Swappable. | |
void | swap (t &lhs, t &rhs) |
Swaps the contents of two objects. More... | |
Requirements for std::EqualityComparable | |
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... | |
Requirements for std::StrictTotallyOrdered | |
You can expect these functions on all types that implement std::StrictTotallyOrdered. | |
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... | |
A combined alphabet that can hold values of either of its alternatives.
...alternative_types | Types of possible values (at least 2); all must model seqan3::alphabet_concept and be unique. |
The union_composition represents the union of two or more alternative alphabets (e.g. the four letter DNA alternative + the gap alternative). It behaves similar to a union or std::variant, but it preserves the seqan3::alphabet_concept.
Short description:
|
inlinenoexcept |
Construction via the value of an alternative.
alternative_t | One of the alternative types. |
alternative | The value of a alternative that should be assigned. |
|
inlinenoexcept |
Construction via the value of a type that an alternative type is constructible from.
indirect_alternative_t | A type that one of the alternative types is constructible from. |
rhs | The value that should be assigned. |
|
inlinenoexceptinherited |
Assign from a character.
Satisfies the seqan3::alphabet_concept::assign_char() requirement via the seqan3::assign_char() wrapper.
Constant.
Guaranteed not to throw.
|
inlinenoexceptinherited |
Assign from a numeric value.
Satisfies the seqan3::semi_alphabet_concept::assign_rank() requirement via the seqan3::assign_rank() wrapper.
Constant.
Guaranteed not to throw.
|
inline |
Convert to the specified alphabet (throws if is_alternative() would be false).
index | Index of the alternative to check for. |
std::bad_variant_access | If the union_alphabet currently holds the value of a different alternative. |
|
inline |
Convert to the specified alphabet (throws if is_alternative() would be false).
alternative_t | The type of the alternative that you wish to check for. |
std::bad_variant_access | If the union_alphabet currently holds the value of a different alternative. |
|
inlinenoexcept |
Convert to the specified alphabet (undefined behaviour if is_alternative() would be false).
index | Index of the alternative to check for. |
|
inlinenoexcept |
Convert to the specified alphabet (undefined behaviour if is_alternative() would be false).
alternative_t | The type of the alternative that you wish to check for. |
|
inlinestaticnoexcept |
Returns true if alternative_t is one of the given alternative types.
alternative_t | The type to check. |
|
inlinenoexcept |
Whether the union alphabet currently holds a value of the given alternative.
index | Index of the alternative to check for. |
|
inlinenoexcept |
Whether the union alphabet currently holds a value of the given alternative.
alternative_t | The type of the alternative that you wish to check for. |
|
inlinenoexcept |
Assignment via a value that one of the alternative types is assignable from.
indirect_alternative_t | A type that one of the alternatives is assignable from. |
rhs | The value of an alternative. |
|
inlinenoexceptinherited |
Return the letter as a character of char_type.
Satisfies the seqan3::alphabet_concept::to_char() requirement via the seqan3::to_char() wrapper.
Constant.
Guaranteed not to throw.
|
inlinenoexceptinherited |
Return the letter's numeric value (rank in the alphabet).
Satisfies the seqan3::semi_alphabet_concept::to_rank() requirement via the to_rank() wrapper.
Constant.
Guaranteed not to throw.