BioC++ core-0.7.0
The Modern C++ libraries for Bioinformatics.
 
Loading...
Searching...
No Matches
semialphabet_any.hpp
Go to the documentation of this file.
1// -----------------------------------------------------------------------------------------------------
2// Copyright (c) 2022 deCODE Genetics
3// Copyright (c) 2006-2020, Knut Reinert & Freie Universität Berlin
4// Copyright (c) 2016-2020, Knut Reinert & MPI für molekulare Genetik
5// This file may be used, modified and/or redistributed under the terms of the 3-clause BSD-License
6// shipped with this file and also available at: https://github.com/biocpp/biocpp-core/blob/main/LICENSE.md
7// -----------------------------------------------------------------------------------------------------
8
14#pragma once
15
16#include <bio/alphabet/base.hpp>
17
18namespace bio::alphabet
19{
20
45template <size_t size_>
46class semialphabet_any : public base<semialphabet_any<size_>, size_, void>
47{
48private:
50 using base_t = base<semialphabet_any<size_>, size_, void>;
51
53 friend base_t;
54
55public:
57 using base_t::to_rank;
58
62 constexpr semialphabet_any() noexcept = default;
63 constexpr semialphabet_any(semialphabet_any const &) noexcept = default;
64 constexpr semialphabet_any(semialphabet_any &&) noexcept = default;
65 constexpr semialphabet_any & operator=(semialphabet_any const &) noexcept = default;
66 constexpr semialphabet_any & operator=(semialphabet_any &&) noexcept = default;
67 ~semialphabet_any() noexcept = default;
68
70 template <meta::different_from<semialphabet_any> other_alph_t>
71 requires(semialphabet<other_alph_t> && size<other_alph_t> == size_)
72 explicit semialphabet_any(other_alph_t const other)
73 {
75 }
77
79 template <meta::different_from<semialphabet_any> other_alph_t>
80 requires(semialphabet<other_alph_t> && (size<other_alph_t> == size_) && std::regular<other_alph_t>)
81 explicit operator other_alph_t() const
82 {
83 other_alph_t other;
84 assign_rank_to(to_rank(), other);
85 return other;
86 }
87};
88
89} // namespace bio::alphabet
Provides bio::alphabet::base.
A CRTP-base that makes defining a custom alphabet easier.
Definition: base.hpp:55
constexpr semialphabet_any< size_ > & assign_rank(rank_type const c) noexcept
Assign from a numeric value.
Definition: base.hpp:168
constexpr rank_type to_rank() const noexcept
Return the letter's numeric value (rank in the alphabet).
Definition: base.hpp:124
A semi-alphabet that type erases all other semi-alphabets of the same size.
Definition: semialphabet_any.hpp:47
constexpr semialphabet_any() noexcept=default
Defaulted.
The basis for bio::alphabet::alphabet, but requires only rank interface (not char).
Definition: concept.hpp:562
constexpr auto size
A type trait that holds the size of a (semi-)alphabet.
Definition: concept.hpp:517
constexpr auto to_rank
Return the rank representation of a (semi-)alphabet object.
Definition: concept.hpp:70
constexpr auto assign_rank_to
Assign a rank to an alphabet object.
Definition: concept.hpp:138
The alphabet module's namespace.
Definition: aa10li.hpp:23