SeqAn3  3.2.0-rc.1
The Modern C++ library for sequence analysis.
semialphabet_any.hpp
Go to the documentation of this file.
1 // -----------------------------------------------------------------------------------------------------
2 // Copyright (c) 2006-2022, Knut Reinert & Freie Universität Berlin
3 // Copyright (c) 2016-2022, Knut Reinert & MPI für molekulare Genetik
4 // This file may be used, modified and/or redistributed under the terms of the 3-clause BSD-License
5 // shipped with this file and also available at: https://github.com/seqan/seqan3/blob/master/LICENSE.md
6 // -----------------------------------------------------------------------------------------------------
7 
13 #pragma once
14 
16 
17 namespace seqan3
18 {
19 
46 template <size_t size>
47 class semialphabet_any : public alphabet_base<semialphabet_any<size>, size, void>
48 {
49 private:
52 
54  friend base_t;
55 
56 public:
57  using base_t::assign_rank;
58  using base_t::to_rank;
59 
63  constexpr semialphabet_any() noexcept = default;
64  constexpr semialphabet_any(semialphabet_any const &) noexcept = default;
65  constexpr semialphabet_any(semialphabet_any &&) noexcept = default;
66  constexpr semialphabet_any & operator=(semialphabet_any const &) noexcept = default;
67  constexpr semialphabet_any & operator=(semialphabet_any &&) noexcept = default;
68  ~semialphabet_any() noexcept = default;
69 
74  template <semialphabet other_alph_t>
75  requires (alphabet_size<other_alph_t> == size)
76  explicit semialphabet_any(other_alph_t const other)
77  {
79  }
81 
86  template <semialphabet other_alph_t>
87  requires ((alphabet_size<other_alph_t> == size) && std::regular<other_alph_t>)
88  explicit operator other_alph_t() const
89  {
90  other_alph_t other{};
91  assign_rank_to(to_rank(), other);
92  return other;
93  }
94 };
95 
96 } // namespace seqan3
Provides seqan3::alphabet_base.
A CRTP-base that makes defining a custom alphabet easier.
Definition: alphabet_base.hpp:57
constexpr rank_type to_rank() const noexcept
Return the letter's numeric value (rank in the alphabet).
Definition: alphabet_base.hpp:137
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:199
constexpr semialphabet_any< size > & assign_rank(rank_type const c) noexcept
Assign from a numeric value.
Definition: alphabet_base.hpp:187
A semi-alphabet that type erases all other semi-alphabets of the same size.
Definition: semialphabet_any.hpp:48
requires(alphabet_size< other_alph_t >==size) explicit semialphabet_any(other_alph_t const other)
Construct semialphabet_any from alphabet of the same size.
Definition: semialphabet_any.hpp:75
requires((alphabet_size< other_alph_t >==size) &&std::regular< other_alph_t >) explicit operator other_alph_t() const
Enable conversion of semialphabet_any into other (semi-)alphabet of the same size.
Definition: semialphabet_any.hpp:87
constexpr semialphabet_any() noexcept=default
Defaulted.
constexpr auto assign_rank_to
Assign a rank to an alphabet object.
Definition: alphabet/concept.hpp:293
constexpr auto to_rank
Return the rank representation of a (semi-)alphabet object.
Definition: alphabet/concept.hpp:155
constexpr size_t size
The size of a type pack.
Definition: type_pack/traits.hpp:146
The basis for seqan3::alphabet, but requires only rank interface (not char).
The main SeqAn3 namespace.
Definition: aligned_sequence_concept.hpp:29