SeqAn3  3.0.1
The Modern C++ library for sequence analysis.
semialphabet_any.hpp
Go to the documentation of this file.
1 // -----------------------------------------------------------------------------------------------------
2 // Copyright (c) 2006-2020, Knut Reinert & Freie Universität Berlin
3 // Copyright (c) 2016-2020, 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) && std::regular<other_alph_t>)
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
alphabet_base.hpp
Provides seqan3::alphabet_base.
seqan3::assign_rank_to
constexpr auto assign_rank_to
Assign a rank to an alphabet object.
Definition: concept.hpp:238
seqan3::semialphabet_any::semialphabet_any
constexpr semialphabet_any() noexcept=default
Defaulted.
seqan3::alphabet_base
A CRTP-base that makes defining a custom alphabet easier.
Definition: alphabet_base.hpp:51
seqan3::to_rank
constexpr auto to_rank
Return the rank representation of a (semi-)alphabet object.
Definition: concept.hpp:142
seqan3::semialphabet_any::operator=
constexpr semialphabet_any & operator=(semialphabet_any const &) noexcept=default
Defaulted.
seqan3::semialphabet_any::~semialphabet_any
~semialphabet_any() noexcept=default
Defaulted.
seqan3
The main SeqAn3 namespace.
Definition: aligned_sequence_concept.hpp:36
seqan3::semialphabet_any
A semi-alphabet that type erases all other semi-alphabets of the same size.
Definition: semialphabet_any.hpp:45
seqan3::pack_traits::size
constexpr size_t size
The size of a type pack.
Definition: traits.hpp:116
regular
Subsumes std::semiregular and std::equality_comparable.
seqan3::alphabet_base< semialphabet_any< size >, size, void >::assign_rank
constexpr semialphabet_any< size > & assign_rank(rank_type const c) noexcept
Assign from a numeric value.
Definition: alphabet_base.hpp:165
seqan3::alphabet_base< semialphabet_any< size >, size, void >::to_rank
constexpr rank_type to_rank() const noexcept
Return the letter's numeric value (rank in the alphabet).
Definition: alphabet_base.hpp:116