tetl 0.1.0
Embedded Template Library
Loading...
Searching...
No Matches
toupper.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_TOUPPER_HPP
5#define TETL_CCTYPE_TOUPPER_HPP
6
7#include <etl/_cctype/islower.hpp>
8
9namespace etl {
10
11/// \brief Converts the given character to uppercase according to the character
12/// conversion rules defined by the default C locale.
13///
14/// In the default "C" locale, the following lowercase letters
15/// **abcdefghijklmnopqrstuvwxyz** are replaced with respective uppercase
16/// letters
17/// **ABCDEFGHIJKLMNOPQRSTUVWXYZ**.
18///
19/// \param ch Character to classify.
20///
21/// \returns Converted character or ch if no uppercase version is defined by the
22/// current C locale.
23///
24/// https://en.cppreference.com/w/cpp/string/byte/toupper
25///
26/// \ingroup cctype
27[[nodiscard]] constexpr auto toupper(int ch) noexcept -> int
28{
29 if (etl::islower(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_TOUPPER_HPP
constexpr auto islower(int ch) noexcept -> int
Checks if the given character is classified as a lowercase character according to the default C local...
Definition islower.hpp:20
constexpr auto toupper(int ch) noexcept -> int
Converts the given character to uppercase according to the character conversion rules defined by the ...
Definition toupper.hpp:27
Definition adjacent_find.hpp:9