A CRTP-base that eases the definition of proxy types returned in place of regular alphabets. More...
#include <bio/alphabet/proxy_base.hpp>
Public Member Functions | |
Write functions | |
All of these call the emulated type's write functions and then delegate to the assignment operator which invokes derived behaviour. | |
constexpr derived_type & | assign_char (char_type const c) noexcept |
Assign from a character, implicitly converts invalid characters. | |
constexpr derived_type const & | assign_char (char_type const c) const noexcept |
Assign from a character, implicitly converts invalid characters. | |
constexpr derived_type & | assign_phred (phred_type const c) noexcept |
Assign from the numeric phred value. | |
constexpr derived_type const & | assign_phred (phred_type const c) const noexcept |
Assign from the numeric phred value. | |
Static Public Attributes | |
static constexpr auto | alphabet_size = bio::alphabet::size<alphabet_type> |
The alphabet size. | |
Friends | |
constexpr void | swap (derived_type &lhs, derived_type &rhs) |
Checks order of lhs and rhs . | |
constexpr void | swap (derived_type const &lhs, derived_type const &rhs) |
Checks order of lhs and rhs . | |
constexpr derived_type & | tag_invoke (custom::assign_char_to, char_type const c, derived_type &a) noexcept |
tag_invoke() wrapper around member. | |
constexpr derived_type const & | tag_invoke (custom::assign_char_to, char_type const c, derived_type const &a) noexcept |
tag_invoke() wrapper around member. | |
constexpr derived_type & | tag_invoke (custom::assign_phred_to, phred_type const p, derived_type &a) noexcept |
tag_invoke() wrapper around member. | |
constexpr derived_type const & | tag_invoke (custom::assign_phred_to, phred_type const p, derived_type const &a) noexcept |
tag_invoke() wrapper around member. | |
constexpr derived_type & | tag_invoke (custom::assign_rank_to, auto const r, derived_type &a) noexcept |
tag_invoke() wrapper around member. | |
constexpr derived_type const & | tag_invoke (custom::assign_rank_to, auto const r, derived_type const &a) noexcept |
tag_invoke() wrapper around member. | |
constexpr bool | tag_invoke (custom::char_is_valid_for, char_type const c, derived_type) noexcept |
tag_invoke() wrapper around member. | |
constexpr bool | tag_invoke (custom::char_is_valid_for, char_type const c, std::type_identity< derived_type >) noexcept |
tag_invoke() wrapper around member. | |
constexpr auto | tag_invoke (custom::complement, derived_type const a) noexcept |
tag_invoke() wrapper around member. | |
consteval auto | tag_invoke (custom::size, derived_type) noexcept |
tag_invoke() wrapper around member. | |
consteval auto | tag_invoke (custom::size, std::type_identity< derived_type >) noexcept |
tag_invoke() wrapper around member. | |
constexpr auto | tag_invoke (custom::to_char, derived_type const a) noexcept |
tag_invoke() wrapper around member. | |
constexpr phred_type | tag_invoke (custom::to_phred, derived_type const a) noexcept |
tag_invoke() wrapper around member. | |
constexpr auto | tag_invoke (custom::to_rank, derived_type const a) noexcept |
tag_invoke() wrapper around member. | |
Comparison operators | |
These are only required if the emulated type allows comparison with types it is not convertible to, e.g. bio::alphabet::variant. | |
constexpr bool | operator== (derived_type const lhs, derived_type const rhs) |
Checks whether the letters lhs and rhs are equal. | |
constexpr auto | operator<=> (derived_type const lhs, derived_type const rhs) |
Checks order of lhs and rhs . | |
template<meta::different_from< derived_type > t> requires (meta::weakly_equality_comparable_with<alphabet_type, t>) | |
constexpr bool | operator== (derived_type const lhs, t const rhs) noexcept |
Allow (in-)equality comparison with types that the emulated type is comparable with. | |
template<meta::different_from< derived_type > t> requires (meta::weakly_equality_comparable_with<alphabet_type, t>) | |
constexpr bool | operator== (t const lhs, derived_type const rhs) noexcept |
Allow (in-)equality comparison with types that the emulated type is comparable with. | |
Read functions | |
All of these call the emulated type's read functions. | |
constexpr | operator alphabet_type () const noexcept |
Implicit conversion to the emulated type. | |
template<typename other_t > requires (std::convertible_to<alphabet_type, other_t>) | |
constexpr | operator other_t () const noexcept |
Implicit conversion to types that the emulated type is convertible to. | |
constexpr auto | to_char () const noexcept |
Return the letter as a character of char_type. | |
constexpr auto | to_phred () const noexcept |
Return the alphabet's value in phred representation. | |
constexpr alphabet_type | complement () const noexcept |
Return the complement of the letter. | |
static constexpr bool | char_is_valid (char_type const c) noexcept |
Delegate to the emulated type's validator. | |
A CRTP-base that eases the definition of proxy types returned in place of regular alphabets.
derived_type | The CRTP parameter type. |
alphabet_type | The type of the alphabet that this proxy emulates; must model at least bio::alphabet::writable_semialphabet and std::regular. |
Certain containers and other data structure hold alphabet values in a non-standard way so they can convert to that alphabet when being accessed, but cannot return a reference to the held value. These data structures may instead return a proxy to the held value which still allows changing it (and updating the underlying data structure to reflect this).
This CRTP base facilitates the definition of such proxies. Most users of BioC++ will not need to understand the details.
This class ensures that the proxy itself also models bio::alphabet::semialphabet, bio::alphabet::alphabet, bio::alphabet::quality, bio::alphabet::nucleotide and/or bio::alphabet::aminoacid if the emulated type models these. This makes sure that function templates which accept the original, also accept the proxy.
The derived type needs to provide a .to_rank()
member and an .assign_rank()
member with the actual implementations. Additionally, there needs to be a const
qualified overload for .assign_rank()
.
Most derived_types will also want to specify the default assignment operator to implement "assign-through" and to also provide a const
-qualified overload of the same.
See bio::ranges::bitcompressed_vector or bio::alphabet::tuple_base for examples of how this class is used.
|
inlineconstexprnoexcept |
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.
|
inlineconstexprnoexcept |
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.
|
inlineconstexprnoexcept |
Assign from the numeric phred value.
Satisfies the bio::alphabet::writable_quality::assign_phred() requirement via the bio::alphabet::assign_rank() wrapper.
Constant.
|
inlineconstexprnoexcept |
Assign from the numeric phred value.
Satisfies the bio::alphabet::writable_quality::assign_phred() requirement via the bio::alphabet::assign_rank() wrapper.
Constant.
|
inlineconstexprnoexcept |
Return the complement of the letter.
See Nucleotide for the actual values.
Provides an implementation for bio::alphabet::complement, required to model bio::alphabet::nucleotide.
Constant.
Guaranteed not to throw.
|
inlineconstexprnoexcept |
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.
|
inlineconstexprnoexcept |
Return the alphabet's value in phred representation.