SeqAn3  3.0.0
The Modern C++ library for sequence analysis.
semialphabet_any.hpp
Go to the documentation of this file.
1 // -----------------------------------------------------------------------------------------------------
2 // Copyright (c) 2006-2019, Knut Reinert & Freie Universität Berlin
3 // Copyright (c) 2016-2019, 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 
44 template <size_t size>
45 class semialphabet_any : public alphabet_base<semialphabet_any<size>, size, void>
46 {
47 private:
50 
52  friend base_t;
53 
54 public:
55  using base_t::to_rank;
56  using base_t::assign_rank;
57 
61  constexpr semialphabet_any() noexcept = default;
62  constexpr semialphabet_any(semialphabet_any const &) noexcept = default;
63  constexpr semialphabet_any(semialphabet_any &&) noexcept = default;
64  constexpr semialphabet_any & operator=(semialphabet_any const &) noexcept = default;
65  constexpr semialphabet_any & operator=(semialphabet_any &&) noexcept = default;
66  ~semialphabet_any() noexcept = default;
67 
69  template <Semialphabet other_alph_t>
71  requires (alphabet_size<other_alph_t> == size)
73  explicit semialphabet_any(other_alph_t const other)
74  {
76  }
78 
80  template <Semialphabet other_alph_t>
82  requires (alphabet_size<other_alph_t> == size)
84  explicit operator other_alph_t() const
85  {
86  other_alph_t other{};
87  assign_rank_to(to_rank(), other);
88  return other;
89  }
90 };
91 
92 } // namespace seqan3
constexpr semialphabet_any & operator=(semialphabet_any const &) noexcept=default
Defaulted.
constexpr auto assign_rank_to
Assign a rank to an alphabet object.
Definition: concept.hpp:207
~semialphabet_any() noexcept=default
Defaulted.
constexpr auto to_rank
Return the rank representation of a (semi-)alphabet object.
Definition: concept.hpp:103
::ranges::size size
Alias for ranges::size. Obtains the size of a range whose size can be calculated in constant time...
Definition: ranges:189
The main SeqAn3 namespace.
A semi-alphabet that type erases all other semi-alphabets of the same size.
Definition: semialphabet_any.hpp:45
constexpr semialphabet_any< size > & assign_rank(rank_type const c) noexcept
Assign from a numeric value.
Definition: alphabet_base.hpp:166
Provides seqan3::alphabet_base.
constexpr rank_type to_rank() const noexcept
Return the letter&#39;s numeric value (rank in the alphabet).
Definition: alphabet_base.hpp:117
constexpr semialphabet_any() noexcept=default
Defaulted.
A CRTP-base that makes defining a custom alphabet easier.
Definition: alphabet_base.hpp:52