21 template <std::
intmax_t _base,
char _str_digit>
struct Digit_impl {
22 static_assert((_str_digit >=
'0' && _str_digit <=
'9') ||
23 (_str_digit >=
'a' && _str_digit <=
'f') ||
24 (_str_digit >=
'A' && _str_digit <=
'F') || _str_digit ==
'\'');
26 static_assert(_base >= 2,
"minimum representation is binary (base = 2)");
27 static_assert(_base < 17,
"maximum representation is hex (base == 16)");
30 static constexpr std::intmax_t
value =
31 (_str_digit >=
'0' && _str_digit <=
'9') ? _str_digit -
'0'
32 : (_str_digit >=
'a' && _str_digit <=
'f') ? 10 + (_str_digit -
'a')
33 : (_str_digit >=
'A' && _str_digit <=
'F')
34 ? 10 + (_str_digit -
'A')
35 : std::numeric_limits<std::intmax_t>::quiet_NaN();
40 template <std::
intmax_t _base,
char _str_digit>
45 template <std::intmax_t _base,
char _digit,
char... _digits>
struct Power_impl {
55 template <std::
intmax_t _base,
char _digit>
struct Power_impl<_base, _digit> {
56 static constexpr std::intmax_t
power = 1;
60 template <std::intmax_t _base,
char... _digits>
64 template <std::
intmax_t _base>
struct Power<_base> {
65 static constexpr std::intmax_t
power = 1;
68 template <std::intmax_t _base,
char _digit,
char... _digits>
struct Magnitude {
72 static constexpr std::intmax_t
value =
76 template <std::
intmax_t _base,
char _digit>
struct Magnitude<_base, _digit> {
77 static constexpr std::intmax_t
value = 0;
81 template <std::intmax_t _base,
char _digit,
char... _digits>
84 static constexpr std::intmax_t
base = _base;
91 static constexpr std::intmax_t
value =
95 "integer literal overflows");
99 template <std::
intmax_t _base,
char _digit>
struct Number_impl<_base, _digit> {
105 static constexpr std::intmax_t
base = _base;
107 static_assert(
power == 1,
"power should be one");
114 template <
char... _digits>
118 template <
char... _digits>
122 template <
char... _digits>
126 template <
char... _digits>
130 template <
char... _digits>
Definition: number_parser.h:17
Definition: number_parser.h:21
static constexpr std::intmax_t value
Definition: number_parser.h:30
static constexpr bool is_valid_digit
Definition: number_parser.h:29
Definition: number_parser.h:41
Definition: number_parser.h:68
static constexpr std::intmax_t value
Definition: number_parser.h:72
static constexpr std::intmax_t recursive_magnitude
Definition: number_parser.h:70
recursive struct that builds the number
Definition: number_parser.h:82
static constexpr std::intmax_t magnitude
Definition: number_parser.h:86
static constexpr std::intmax_t value
Definition: number_parser.h:91
static constexpr std::intmax_t base
Definition: number_parser.h:84
static constexpr std::intmax_t power
Definition: number_parser.h:88
interface class for number
Definition: number_parser.h:111
Definition: number_parser.h:45
static constexpr std::intmax_t power
Definition: number_parser.h:49
interface class for power calculation
Definition: number_parser.h:61