Loading...
Searching...
No Matches
transform.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 <array>
#include <seqan3/utility/concept.hpp>
#include <seqan3/utility/detail/integer_traits.hpp>
namespace seqan3::detail
{
template <typename char_type>
inline constexpr std::array<char_type, detail::size_in_values_v<char_type>> to_lower_table{
[]() constexpr
{
std::array<char_type, detail::size_in_values_v<char_type>> ret{};
for (size_t i = 0; i < detail::size_in_values_v<char_type>; ++i)
ret[i] = i;
for (size_t i = char_type{'A'}; i <= char_type{'Z'}; ++i)
ret[i] = ret[i] - char_type{'A'} + char_type{'a'};
return ret;
}()};
template <typename char_type>
inline constexpr std::array<char_type, detail::size_in_values_v<char_type>> to_upper_table{
[]() constexpr
{
std::array<char_type, detail::size_in_values_v<char_type>> ret{};
for (size_t i = 0; i < detail::size_in_values_v<char_type>; ++i)
ret[i] = i;
for (size_t i = char_type{'a'}; i <= char_type{'z'}; ++i)
ret[i] = ret[i] - char_type{'a'} + char_type{'A'};
return ret;
}()};
} // namespace seqan3::detail
namespace seqan3
{
template <builtin_character char_type>
constexpr char_type to_lower(char_type const c) noexcept
{
using u_t = std::make_unsigned_t<char_type>;
return detail::to_lower_table<char_type>[static_cast<u_t>(c)];
}
template <builtin_character char_type>
constexpr char_type to_upper(char_type const c) noexcept
{
using u_t = std::make_unsigned_t<char_type>;
return detail::to_upper_table<char_type>[static_cast<u_t>(c)];
}
} // namespace seqan3
array
integer_traits.hpp
Provides metaprogramming utilities for integer types.
std::make_unsigned_t
seqan3
The main SeqAn3 namespace.
Definition aligned_sequence_concept.hpp:26
seqan3::to_upper
constexpr char_type to_upper(char_type const c) noexcept
Converts 'a'-'z' to 'A'-'Z' respectively; other characters are returned as is.
Definition transform.hpp:90
seqan3::to_lower
constexpr char_type to_lower(char_type const c) noexcept
Converts 'A'-'Z' to 'a'-'z' respectively; other characters are returned as is.
Definition transform.hpp:74
concept.hpp
Provides concepts that do not have equivalents in C++20.
Hide me