tetl 0.1.0
Embedded Template Library
Loading...
Searching...
No Matches
isalnum.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_ISALNUM_HPP
5#define TETL_CCTYPE_ISALNUM_HPP
6
7namespace etl {
8/// \brief Checks if the given character is an alphanumeric character as
9/// classified by the default C locale.
10///
11/// \param ch Character to classify.
12///
13/// \returns Non-zero value if the character is an alphanumeric character, 0
14/// otherwise.
15///
16/// https://en.cppreference.com/w/cpp/string/byte/isalnum
17///
18/// \ingroup cctype
19[[nodiscard]] constexpr auto isalnum(int ch) noexcept -> int
20{
21 auto const isDigit = ch >= '0' and ch <= '9';
22 auto const isLower = ch >= 'a' and ch <= 'z';
23 auto const isUpper = ch >= 'A' and ch <= 'Z';
24
25 return static_cast<int>(isDigit || isLower || isUpper);
26}
27
28} // namespace etl
29#endif // TETL_CCTYPE_ISALNUM_HPP
constexpr auto isalnum(int ch) noexcept -> int
Checks if the given character is an alphanumeric character as classified by the default C locale.
Definition isalnum.hpp:19
Definition adjacent_find.hpp:9