Loading...
Searching...
No Matches
uint.hpp
Go to the documentation of this file.
// SPDX-FileCopyrightText: 2006-2025 Knut Reinert & Freie Universität Berlin
// SPDX-FileCopyrightText: 2016-2025 Knut Reinert & MPI für molekulare Genetik
// SPDX-License-Identifier: BSD-3-Clause
#pragma once
#include <seqan3/alphabet/concept.hpp>
#include <seqan3/utility/detail/integer_traits.hpp>
namespace seqan3::detail
{
template <typename type>
constexpr bool is_uint_adaptation_v =
std::same_as<type, uint8_t> || std::same_as<type, uint16_t> || std::same_as<type, uint32_t>;
} // namespace seqan3::detail
namespace seqan3::custom
{
template <typename uint_type>
requires seqan3::detail::is_uint_adaptation_v<uint_type>
struct alphabet<uint_type>
{
static constexpr auto alphabet_size =
detail::min_viable_uint_t<detail::size_in_values_v<uint_type>>{detail::size_in_values_v<uint_type>};
static constexpr auto to_char(uint_type const uint_v) noexcept
{
if constexpr (std::same_as<uint_type, uint8_t>)
return static_cast<char>(uint_v);
else if constexpr (std::same_as<uint_type, uint16_t>)
return static_cast<char16_t>(uint_v);
else
return static_cast<char32_t>(uint_v);
}
static constexpr uint_type to_rank(uint_type const uint_v) noexcept
{
return uint_v;
}
static constexpr uint_type & assign_char_to(decltype(to_char(uint_type{})) const chr, uint_type & uint_v) noexcept
{
return uint_v = chr;
}
static constexpr uint_type & assign_rank_to(uint_type const uint2_v, uint_type & uint_v) noexcept
{
return uint_v = uint2_v;
}
};
} // namespace seqan3::custom
concept.hpp
Core alphabet concept and free function/type trait wrappers.
seqan3::to_char
constexpr auto to_char
Return the char representation of an alphabet object.
Definition alphabet/concept.hpp:381
integer_traits.hpp
Provides metaprogramming utilities for integer types.
seqan3::custom
A namespace for third party and standard library specialisations of SeqAn customisation points.
Definition char.hpp:40
seqan3::custom::alphabet< uint_type >::assign_rank_to
static constexpr uint_type & assign_rank_to(uint_type const uint2_v, uint_type &uint_v) noexcept
Assign a rank to the uint (same as calling =).
Definition uint.hpp:104
seqan3::custom::alphabet< uint_type >::to_char
static constexpr auto to_char(uint_type const uint_v) noexcept
Converting uint to char casts to a character type of same size.
Definition uint.hpp:64
seqan3::custom::alphabet< uint_type >::to_rank
static constexpr uint_type to_rank(uint_type const uint_v) noexcept
Converting uint to rank is a no-op (it will just return the value you pass in).
Definition uint.hpp:80
seqan3::custom::alphabet< uint_type >::alphabet_size
static constexpr auto alphabet_size
Return the number of values the uint type can take (e.g. 256 for uint8_t).
Definition uint.hpp:55
seqan3::custom::alphabet< uint_type >::assign_char_to
static constexpr uint_type & assign_char_to(decltype(to_char(uint_type{})) const chr, uint_type &uint_v) noexcept
Assign from a character type via implicit or explicit cast.
Definition uint.hpp:92
seqan3::custom::alphabet
A type that can be specialised to provide customisation point implementations so that third party typ...
Definition alphabet/concept.hpp:46
Hide me