SeqAn3  3.0.3
The Modern C++ library for sequence analysis.
semialphabet_any.hpp
Go to the documentation of this file.
1 // -----------------------------------------------------------------------------------------------------
2 // Copyright (c) 2006-2021, Knut Reinert & Freie Universität Berlin
3 // Copyright (c) 2016-2021, 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::to_rank;
58  using base_t::assign_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>
76  requires (alphabet_size<other_alph_t> == size)
78  explicit semialphabet_any(other_alph_t const other)
79  {
81  }
83 
88  template <semialphabet other_alph_t>
90  requires ((alphabet_size<other_alph_t> == size) && std::regular<other_alph_t>)
92  explicit operator other_alph_t() const
93  {
94  other_alph_t other{};
95  assign_rank_to(to_rank(), other);
96  return other;
97  }
98 };
99 
100 } // namespace seqan3
Provides seqan3::alphabet_base.
A CRTP-base that makes defining a custom alphabet easier.
Definition: alphabet_base.hpp:81
constexpr rank_type to_rank() const noexcept
Return the letter's numeric value (rank in the alphabet).
Definition: alphabet_base.hpp:185
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 semialphabet_any< size > & assign_rank(rank_type const c) noexcept
Assign from a numeric value.
Definition: alphabet_base.hpp:264
A semi-alphabet that type erases all other semi-alphabets of the same size.
Definition: semialphabet_any.hpp:48
constexpr semialphabet_any() noexcept=default
Defaulted.
constexpr auto assign_rank_to
Assign a rank to an alphabet object.
Definition: concept.hpp:291
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
The basis for seqan3::alphabet, but requires only rank interface (not char).
The main SeqAn3 namespace.
Definition: aligned_sequence_concept.hpp:29