22 #ifdef SEQAN3_DEPRECATED_310
23 namespace seqan3::detail
27 template <
typename alphabet_t>
28 SEQAN3_CONCEPT has_rank_to_char_table = requires()
30 { alphabet_t::rank_to_char[0] };
36 template <
typename alphabet_t>
37 SEQAN3_CONCEPT has_char_to_rank_table = requires()
39 { alphabet_t::char_to_rank[0] };
79 template <
typename derived_type,
size_t size,
typename char_t =
char>
83 static_assert(
size != 0,
"alphabet size must be >= 1");
141 requires (!
std::same_as<char_t,
void>)
144 #ifdef SEQAN3_DEPRECATED_310
145 if constexpr (detail::has_rank_to_char_table<derived_type>)
146 return rank_to_char_table(rank);
148 return derived_type::rank_to_char(rank);
150 return derived_type::rank_to_char(rank);
154 #ifdef SEQAN3_DEPRECATED_310
163 return derived_type::rank_to_char[rank];
213 requires (!std::same_as<char_t, void>)
216 #ifdef SEQAN3_DEPRECATED_310
217 if constexpr (detail::has_char_to_rank_table<derived_type>)
218 rank = char_to_rank_table(chr);
220 rank = derived_type::char_to_rank(chr);
222 rank = derived_type::char_to_rank(chr);
225 return static_cast<derived_type &
>(*this);
228 #ifdef SEQAN3_DEPRECATED_310
238 #if SEQAN3_WORKAROUND_GCC_99318
239 # pragma GCC diagnostic ignored "-Wdeprecated-declarations"
241 return derived_type::char_to_rank[
static_cast<index_t
>(chr)];
266 assert(
static_cast<size_t>(c) <
static_cast<size_t>(
alphabet_size));
268 return static_cast<derived_type &
>(*this);
285 friend constexpr
bool operator==(derived_type
const lhs, derived_type
const rhs) noexcept
294 friend constexpr
bool operator!=(derived_type
const lhs, derived_type
const rhs) noexcept
303 friend constexpr
bool operator<(derived_type
const lhs, derived_type
const rhs) noexcept
312 friend constexpr
bool operator>(derived_type
const lhs, derived_type
const rhs) noexcept
321 friend constexpr
bool operator<=(derived_type
const lhs, derived_type
const rhs) noexcept
330 friend constexpr
bool operator>=(derived_type
const lhs, derived_type
const rhs) noexcept
Core alphabet concept and free function/type trait wrappers.
A CRTP-base that makes defining a custom alphabet easier.
Definition: alphabet_base.hpp:81
constexpr char_type to_char() const noexcept
Return the letter as a character of char_type.
Definition: alphabet_base.hpp:139
constexpr friend bool operator==(derived_type const lhs, derived_type const rhs) noexcept
Checks whether the letters lhs and rhs are equal.
Definition: alphabet_base.hpp:285
constexpr friend bool operator>(derived_type const lhs, derived_type const rhs) noexcept
Checks whether the letter lhs is greater than rhs.
Definition: alphabet_base.hpp:312
constexpr alphabet_base() noexcept=default
Defaulted.
constexpr rank_type to_rank() const noexcept
Return the letter's numeric value (rank in the alphabet).
Definition: alphabet_base.hpp:185
detail::min_viable_uint_t< size - 1 > rank_type
The type of the alphabet when represented as a number (e.g. via to_rank()).
Definition: alphabet_base.hpp:104
constexpr derived_type & assign_char(char_type const chr) noexcept
Assign from a character, implicitly converts invalid characters.
Definition: alphabet_base.hpp:211
static constexpr detail::min_viable_uint_t< size > alphabet_size
The size of the alphabet, i.e. the number of different values it can take.
Definition: alphabet_base.hpp:276
constexpr friend bool operator<(derived_type const lhs, derived_type const rhs) noexcept
Checks whether the letter lhs is smaller than rhs.
Definition: alphabet_base.hpp:303
constexpr derived_type & assign_rank(rank_type const c) noexcept
Assign from a numeric value.
Definition: alphabet_base.hpp:264
constexpr friend bool operator!=(derived_type const lhs, derived_type const rhs) noexcept
Checks whether the letters lhs and rhs are unequal.
Definition: alphabet_base.hpp:294
constexpr friend bool operator>=(derived_type const lhs, derived_type const rhs) noexcept
Checks whether the letter lhs is bigger than or equal to rhs.
Definition: alphabet_base.hpp:330
constexpr friend bool operator<=(derived_type const lhs, derived_type const rhs) noexcept
Checks whether the letter lhs is smaller than or equal to rhs.
Definition: alphabet_base.hpp:321
std::conditional_t< std::same_as< char_t, void >, char, char_t > char_type
The char representation; conditional needed to make semi alphabet definitions legal.
Definition: alphabet_base.hpp:96
constexpr auto to_rank
Return the rank representation of a (semi-)alphabet object.
Definition: concept.hpp:155
constexpr size_t size
The size of a type pack.
Definition: traits.hpp:151
Provides metaprogramming utilities for integer types.
The main SeqAn3 namespace.
Definition: aligned_sequence_concept.hpp:29
SeqAn specific customisations in the standard namespace.
Provides C++20 additions to the type_traits header.