|
(Note that these are not member functions.)
|
|
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...
|
|
|
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...
|
|
The generic alphabet concept that covers most data types used in ranges.
This is the core alphabet concept that many other alphabet concepts refine.
For a detailed overview of how the different alphabet concepts are related, see Alphabet module.
Requirements
t
shall model seqan3::Semialphabet ("has all rank representation")
- seqan3::to_char needs to be defined for objects of type
t
See the documentation pages for the respective requirements.
Related types
If a given type t
models this concept, the following types typically do so, as well:
Writing your own alphabet
This is an example of a minimal custom alphabet that provides implementations for all necessary customisation points:
namespace my_namespace
{
enum class my_alph
{
ZERO,
ONE,
TWO
};
{
return 3;
}
constexpr
size_t to_rank(my_alph
const a) noexcept
{
return static_cast<size_t>(a);
}
constexpr my_alph &
assign_rank_to(
size_t const r, my_alph & a) noexcept
{
switch (r)
{
case 0: a = my_alph::ZERO; return a;
case 1: a = my_alph::ONE; return a;
default: a = my_alph::TWO; return a;
}
}
constexpr
char to_char(my_alph
const a) noexcept
{
switch (a)
{
case my_alph::ZERO: return '0';
case my_alph::ONE: return '1';
default: return '2';
}
}
constexpr my_alph &
assign_char_to(
char const c, my_alph & a) noexcept
{
switch (c)
{
case '0': a = my_alph::ZERO; return a;
case '1': a = my_alph::ONE; return a;
default: a = my_alph::TWO; return a;
}
}
}
This is an example of a custom alphabet that is not default-constructible and that has a non-default overload for seqan3::char_is_valid_for:
namespace my_namespace
{
class my_alph
{
public:
bool b;
my_alph() = delete;
constexpr my_alph(my_alph const &) = default;
constexpr my_alph & operator=(my_alph const &) = default;
constexpr my_alph(bool _b) : b{_b} {}
constexpr
friend bool operator==(my_alph lhs, my_alph rhs) {
return lhs.b == rhs.b; }
constexpr
friend bool operator!=(my_alph lhs, my_alph rhs) {
return lhs.b != rhs.b; }
constexpr
friend bool operator<=(my_alph lhs, my_alph rhs) {
return lhs.b <= rhs.b; }
constexpr
friend bool operator>=(my_alph lhs, my_alph rhs) {
return lhs.b >= rhs.b; }
constexpr
friend bool operator< (my_alph lhs, my_alph rhs) {
return lhs.b < rhs.b; }
constexpr
friend bool operator> (my_alph lhs, my_alph rhs) {
return lhs.b > rhs.b; }
};
{
return 2;
}
constexpr
bool to_rank(my_alph
const a) noexcept
{
return a.b;
}
constexpr my_alph &
assign_rank_to(
bool const r, my_alph & a) noexcept
{
a.b = r;
return a;
}
constexpr
char to_char(my_alph
const a) noexcept
{
if (a.b)
return '1';
else
return '0';
}
constexpr my_alph &
assign_char_to(
char const c, my_alph & a) noexcept
{
switch (c)
{
case '0': case 'F': case 'f': a.b = 0; return a;
default: a.b = 1; return a;
}
}
{
switch (c)
{
case '0': case 'F': case 'f': case '1': case 'T': case 't': return true;
default: return false;
}
}
}
static_assert(seqan3::alphabet_size<my_namespace::my_alph> == 2);
static_assert(seqan3::char_is_valid_for<my_namespace::my_alph>('T'));
static_assert(!seqan3::char_is_valid_for<my_namespace::my_alph>('!'));
(Note that you should really make your alphabet types no-throw-default-constructible if you can!)