|
|
Defines comparison against types that are not subject to implicit construction/conversion but are comparable against alternatives, e.g. alphabet_variant<seqan3::rna4, seqan3::gap> vs alphabet_variant<seqan3::dna4, seqan3::gap> . Only (in-)equality comparison is defined as reasoning about order of variants is inherently difficult.
|
template<typename alphabet_variant_t , typename indirect_alternative_type > |
constexpr friend auto | operator== (alphabet_variant_t const lhs, indirect_alternative_type const rhs) noexcept -> std::enable_if_t< detail::variant_comparison_guard< alphabet_variant_t, indirect_alternative_type, false, alternative_types... >, bool > |
| (In-)Equality comparison against types comparable with alternatives but not convertible to the variant. More...
|
|
template<typename alphabet_variant_t , typename indirect_alternative_type > |
constexpr friend auto | operator!= (alphabet_variant_t const lhs, indirect_alternative_type const rhs) noexcept -> std::enable_if_t< detail::variant_comparison_guard< alphabet_variant_t, indirect_alternative_type, false, alternative_types... >, bool > |
| (In-)Equality comparison against types comparable with alternatives but not convertible to the variant. More...
|
|
template<typename alphabet_variant_t , typename indirect_alternative_type , typename = void> |
constexpr friend auto | operator== (indirect_alternative_type const lhs, alphabet_variant_t const rhs) noexcept -> std::enable_if_t< detail::variant_comparison_guard< alphabet_variant_t, indirect_alternative_type, true, alternative_types... >, bool > |
| (In-)Equality comparison against types comparable with alternatives but not convertible to the variant. More...
|
|
template<typename alphabet_variant_t , typename indirect_alternative_type , typename = void> |
constexpr friend auto | operator!= (indirect_alternative_type const lhs, alphabet_variant_t const rhs) noexcept -> std::enable_if_t< detail::variant_comparison_guard< alphabet_variant_t, indirect_alternative_type, true, alternative_types... >, bool > |
| (In-)Equality comparison against types comparable with alternatives but not convertible to the variant. More...
|
|
|
(Note that these are not member functions.)
|
|
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...
|
|
|
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...
|
|
|
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...
|
|
template<typename ... alternative_types>
class seqan3::alphabet_variant< alternative_types >
A combined alphabet that can hold values of either of its alternatives.
- Template Parameters
-
The alphabet_variant represents the union of two or more alternative alphabets (e.g. the four letter DNA alternative + the gap alternative). It behaves similar to a variant or std::variant, but it preserves the seqan3::alphabet.
Short description:
- combines multiple different alphabets in an "either-or"-fashion;
- is itself a seqan3::alphabet;
- its alphabet size is the sum of the individual sizes;
- default initialises to the the first alternative's default (no empty state like std::variant);
- constructible, assignable and (in-)equality-comparable with each alternative type and also all types that these are constructible/assignable/equality-comparable with;
- only convertible to its alternatives through the member function convert_to() (which can throw!)
Example
int main()
{
using seqan3::operator""_dna5;
using seqan3::operator""_rna5;
letter2.assign_char('-');
letter2.assign_char('K');
letter2 = 'U'_rna5;
}
Part of the seqan3::alphabet concept requires that the alphabet_variant provides a char representation in addition to the rank representation. For an object of seqan3::alphabet_variant, the to_char()
member function will always return the same character as if invoked on the respective alternative. In contrast, the assign_char()
member function might be ambiguous between the alternative alphabets in a variant.
For example, assigning a '!' to seqan3::dna15 resolves to an object of rank 8 with char representation 'N' while assigning '!' to seqan3::gap always resolves to rank 0, the gap symbol itself ('-'_gap). We tackle this ambiguousness by defaulting unknown characters to the representation of the first alternative (e.g. ‘alphabet_variant<dna15, gap>{}.assign_char(’!')resolves to rank 8, representing
N`_dna15).
On the other hand, two alternative alphabets might have the same char representation (e.g if you combine dna4 with dna5, 'A', 'C', 'G' and 'T' are ambiguous). We tackle this ambiguousness by always choosing the first valid char representation (e.g. ‘alphabet_variant<dna4, dna5>{}.assign_char('A’)resolves to rank 0, representing an
A`_dna4).
To explicitly assign via the character representation of a specific alphabet, assign to that type first and then assign to the variant, e.g.
int main()
{
using seqan3::operator""_dna5;
var = 'A'_dna5;
}
template<typename ... alternative_types>
template<typename alphabet_variant_t , typename indirect_alternative_type >
constexpr friend auto operator!= |
( |
alphabet_variant_t const |
lhs, |
|
|
indirect_alternative_type const |
rhs |
|
) |
| -> std::enable_if_t<detail::variant_comparison_guard<alphabet_variant_t,
indirect_alternative_type,
false,
alternative_types...>,
bool>
|
|
friend |
(In-)Equality comparison against types comparable with alternatives but not convertible to the variant.
- Template Parameters
-
alphabet_variant_t | The type of the variant; given as template parameter to prevent conversion. |
indirect_alternative_type | Must be comparable with an alternative's type. |
- Parameters
-
lhs | Left-hand-side of comparison. |
rhs | Right-hand-side of comparison. |
- Returns
true
or false
.
To determine (in-)equality, it is first deduced which alternative the argument is comparable with. It is then checked if the variant currently is in that alternative's state and if yes whether the values compare to true
; else false
is returned.
template<typename ... alternative_types>
template<typename alphabet_variant_t , typename indirect_alternative_type , typename = void>
constexpr friend auto operator!= |
( |
indirect_alternative_type const |
lhs, |
|
|
alphabet_variant_t const |
rhs |
|
) |
| -> std::enable_if_t<detail::variant_comparison_guard<alphabet_variant_t,
indirect_alternative_type,
true,
alternative_types...>,
bool>
|
|
friend |
(In-)Equality comparison against types comparable with alternatives but not convertible to the variant.
- Template Parameters
-
alphabet_variant_t | The type of the variant; given as template parameter to prevent conversion. |
indirect_alternative_type | Must be comparable with an alternative's type. |
- Parameters
-
lhs | Left-hand-side of comparison. |
rhs | Right-hand-side of comparison. |
- Returns
true
or false
.
To determine (in-)equality, it is first deduced which alternative the argument is comparable with. It is then checked if the variant currently is in that alternative's state and if yes whether the values compare to true
; else false
is returned.
template<typename ... alternative_types>
template<typename alphabet_variant_t , typename indirect_alternative_type >
constexpr friend auto operator== |
( |
alphabet_variant_t const |
lhs, |
|
|
indirect_alternative_type const |
rhs |
|
) |
| -> std::enable_if_t<detail::variant_comparison_guard<alphabet_variant_t,
indirect_alternative_type,
false,
alternative_types...>,
bool>
|
|
friend |
(In-)Equality comparison against types comparable with alternatives but not convertible to the variant.
- Template Parameters
-
alphabet_variant_t | The type of the variant; given as template parameter to prevent conversion. |
indirect_alternative_type | Must be comparable with an alternative's type. |
- Parameters
-
lhs | Left-hand-side of comparison. |
rhs | Right-hand-side of comparison. |
- Returns
true
or false
.
To determine (in-)equality, it is first deduced which alternative the argument is comparable with. It is then checked if the variant currently is in that alternative's state and if yes whether the values compare to true
; else false
is returned.
template<typename ... alternative_types>
template<typename alphabet_variant_t , typename indirect_alternative_type , typename = void>
constexpr friend auto operator== |
( |
indirect_alternative_type const |
lhs, |
|
|
alphabet_variant_t const |
rhs |
|
) |
| -> std::enable_if_t<detail::variant_comparison_guard<alphabet_variant_t,
indirect_alternative_type,
true,
alternative_types...>,
bool>
|
|
friend |
(In-)Equality comparison against types comparable with alternatives but not convertible to the variant.
- Template Parameters
-
alphabet_variant_t | The type of the variant; given as template parameter to prevent conversion. |
indirect_alternative_type | Must be comparable with an alternative's type. |
- Parameters
-
lhs | Left-hand-side of comparison. |
rhs | Right-hand-side of comparison. |
- Returns
true
or false
.
To determine (in-)equality, it is first deduced which alternative the argument is comparable with. It is then checked if the variant currently is in that alternative's state and if yes whether the values compare to true
; else false
is returned.