SeqAn3  3.0.1
The Modern C++ library for sequence analysis.
uint.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 
26 #pragma once
27 
30 
31 namespace seqan3::detail
32 {
35 template <typename type>
36 constexpr bool is_uint_adaptation_v = std::same_as<type, uint8_t> ||
39 } // namespace seqan3::detail
40 
41 namespace seqan3::custom
42 {
43 
48 template <typename uint_type>
50  requires seqan3::detail::is_uint_adaptation_v<uint_type>
52 struct alphabet<uint_type>
53 {
55  static constexpr auto alphabet_size =
56  detail::min_viable_uint_t<detail::size_in_values_v<uint_type>>{detail::size_in_values_v<uint_type>};
57 
62  static constexpr auto to_char(uint_type const intgr) noexcept
63  {
65  return static_cast<char>(intgr);
66  else if constexpr (std::same_as<uint_type, uint16_t>)
67  return static_cast<char16_t>(intgr);
68  else
69  return static_cast<char32_t>(intgr);
70  }
71 
76  static constexpr uint_type to_rank(uint_type const intgr) noexcept
77  {
78  return intgr;
79  }
80 
86  static constexpr uint_type & assign_char_to(decltype(to_char(uint_type{})) const chr, uint_type & intgr) noexcept
87  {
88  return intgr = chr;
89  }
90 
96  static constexpr uint_type & assign_rank_to(uint_type const intgr2, uint_type & intgr) noexcept
97  {
98  return intgr = intgr2;
99  }
100 };
101 
102 } // namespace seqan3::custom
seqan3::custom::alphabet
A type that can be specialised to provide customisation point implementations so that third party typ...
Definition: concept.hpp:46
seqan3::custom::alphabet< uint_type >::assign_rank_to
static constexpr uint_type & assign_rank_to(uint_type const intgr2, uint_type &intgr) noexcept
Assign a rank to to the uint (same as calling =).
Definition: uint.hpp:96
seqan3::to_char
constexpr auto to_char
Return the char representation of an alphabet object.
Definition: concept.hpp:320
seqan3::custom::alphabet< uint_type >::to_rank
static constexpr uint_type to_rank(uint_type const intgr) noexcept
Converting uint to rank is a no-op (it will just return the value you pass in).
Definition: uint.hpp:76
same_as
The concept std::same_as<T, U> is satisfied if and only if T and U denote the same type.
seqan3::custom::alphabet< uint_type >::to_char
static constexpr auto to_char(uint_type const intgr) noexcept
Converting uint to char casts to a character type of same size.
Definition: uint.hpp:62
int_types.hpp
Provides metaprogramming utilities for integer types.
seqan3::custom::alphabet< uint_type >::assign_char_to
static constexpr uint_type & assign_char_to(decltype(to_char(uint_type{})) const chr, uint_type &intgr) noexcept
Assign from a character type via implicit or explicit cast.
Definition: uint.hpp:86
std::conditional_t
seqan3::alphabet_size
constexpr auto alphabet_size
A type trait that holds the size of a (semi-)alphabet.
Definition: concept.hpp:706
concept.hpp
Core alphabet concept and free function/type trait wrappers.
seqan3::custom
A namespace for third party and standard library specialisations of SeqAn customisation points.
Definition: char.hpp:42