tetl 0.1.0
Embedded Template Library
Loading...
Searching...
No Matches
tolower.hpp
Go to the documentation of this file.
1// SPDX-License-Identifier: BSL-1.0
2// SPDX-FileCopyrightText: Copyright (C) 2020 Tobias Hienzsch
3
4#ifndef TETL_CCTYPE_TOLOWER_HPP
5#define TETL_CCTYPE_TOLOWER_HPP
6
7#include <etl/_cctype/isupper.hpp>
8
9namespace etl {
10
11/// \brief Converts the given character to lowercase according to the character
12/// conversion rules defined by the default C locale.
13///
14/// In the default "C" locale, the following uppercase letters
15/// **ABCDEFGHIJKLMNOPQRSTUVWXYZ** are replaced with respective lowercase
16/// letters
17/// **abcdefghijklmnopqrstuvwxyz**.
18///
19/// \param ch Character to classify.
20///
21/// \returns Lowercase version of ch or unmodified ch if no lowercase version is
22/// listed in the current C locale.
23///
24/// https://en.cppreference.com/w/cpp/string/byte/tolower
25///
26/// \ingroup cctype
27[[nodiscard]] constexpr auto tolower(int ch) noexcept -> int
28{
29 if (isupper(ch) != 0) {
30 return static_cast<int>(ch + 32);
31 }
32 return static_cast<int>(ch);
33}
34} // namespace etl
35
36#endif // TETL_CCTYPE_TOLOWER_HPP
constexpr auto isupper(int ch) noexcept -> int
Checks if the given character is classified as a uppercase character according to the default C local...
Definition isupper.hpp:20
constexpr auto tolower(int ch) noexcept -> int
Converts the given character to lowercase according to the character conversion rules defined by the ...
Definition tolower.hpp:27
Definition adjacent_find.hpp:9