VIPA 0.1.0
Header-only C++23 SIMD-assisted IPv4/IPv6 text parser.
Loading...
Searching...
No Matches
classify.hxx
Go to the documentation of this file.
1#pragma once
2
3#include <cstdint>
4
6
8constexpr bool is_hex_digit(char c) noexcept {
9 return (c >= '0' && c <= '9') || (c >= 'a' && c <= 'f') ||
10 (c >= 'A' && c <= 'F');
11}
12
14constexpr auto hex_value(char c) noexcept -> uint8_t {
15 if (c >= '0' && c <= '9')
16 return static_cast<uint8_t>(c - '0');
17 if (c >= 'a' && c <= 'f')
18 return static_cast<uint8_t>(10 + c - 'a');
19 return static_cast<uint8_t>(10 + c - 'A');
20}
21
22} // namespace llmx::vipa::detail
Definition classify.hxx:5
constexpr bool is_hex_digit(char c) noexcept
Return true when c is an ASCII hexadecimal digit.
Definition classify.hxx:8
constexpr auto hex_value(char c) noexcept -> uint8_t
Convert an ASCII hexadecimal digit to its numeric value.
Definition classify.hxx:14