SeqAn3 3.4.0-rc.1
The Modern C++ library for sequence analysis.
Loading...
Searching...
No Matches
transform.hpp
Go to the documentation of this file.
1// SPDX-FileCopyrightText: 2006-2024 Knut Reinert & Freie Universität Berlin
2// SPDX-FileCopyrightText: 2016-2024 Knut Reinert & MPI für molekulare Genetik
3// SPDX-License-Identifier: BSD-3-Clause
4
10#pragma once
11
12#include <array>
13
16
17namespace seqan3::detail
18{
19
20// clang-format off
23template <typename char_type>
25{
26 []() constexpr
27 {
29
30 for (size_t i = 0; i < detail::size_in_values_v<char_type>; ++i)
31 ret[i] = i;
32
33 for (size_t i = char_type{'A'}; i <= char_type{'Z'}; ++i)
34 ret[i] = ret[i] - char_type{'A'} + char_type{'a'};
35
36 return ret;
37 }()
38};
39
42template <typename char_type>
44{
45 []() constexpr
46 {
48
49 for (size_t i = 0; i < detail::size_in_values_v<char_type>; ++i)
50 ret[i] = i;
51
52 for (size_t i = char_type{'a'}; i <= char_type{'z'}; ++i)
53 ret[i] = ret[i] - char_type{'a'} + char_type{'A'};
54
55 return ret;
56 }()
57};
58// clang-format on
59
60} // namespace seqan3::detail
61
62namespace seqan3
63{
64
79template <builtin_character char_type>
80constexpr char_type to_lower(char_type const c) noexcept
81{
83 return detail::to_lower_table<char_type>[static_cast<u_t>(c)];
84}
85
95template <builtin_character char_type>
96constexpr char_type to_upper(char_type const c) noexcept
97{
99 return detail::to_upper_table<char_type>[static_cast<u_t>(c)];
100}
102
103} // namespace seqan3
constexpr std::array< char_type, detail::size_in_values_v< char_type > > to_lower_table
Auxiliary table for seqan3::to_lower.
Definition transform.hpp:25
constexpr std::array< char_type, detail::size_in_values_v< char_type > > to_upper_table
Auxiliary table for seqan3::to_upper.
Definition transform.hpp:44
Provides metaprogramming utilities for integer types.
The internal SeqAn3 namespace.
Definition aligned_sequence_concept.hpp:26
The main SeqAn3 namespace.
Definition aligned_sequence_concept.hpp:26
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:96
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:80
Provides concepts that do not have equivalents in C++20.
Hide me