30#ifndef _GLIBCXX_PARSE_NUMBERS_H
31#define _GLIBCXX_PARSE_NUMBERS_H 1
34#pragma GCC system_header
39#if __cplusplus >= 201402L
44namespace std _GLIBCXX_VISIBILITY(default)
46_GLIBCXX_BEGIN_NAMESPACE_VERSION
50 template<
unsigned _Base,
char _Dig>
53 template<
unsigned _Base>
54 struct _Digit<_Base, '0'> : integral_constant<unsigned, 0>
59 template<
unsigned _Base>
60 struct _Digit<_Base, '1'> : integral_constant<unsigned, 1>
65 template<
unsigned _Base,
unsigned _Val>
66 struct _Digit_impl : integral_constant<unsigned, _Val>
68 static_assert(_Base > _Val,
"invalid digit");
72 template<
unsigned _Base>
73 struct _Digit<_Base, '2'> : _Digit_impl<_Base, 2>
76 template<
unsigned _Base>
77 struct _Digit<_Base, '3'> : _Digit_impl<_Base, 3>
80 template<
unsigned _Base>
81 struct _Digit<_Base, '4'> : _Digit_impl<_Base, 4>
84 template<
unsigned _Base>
85 struct _Digit<_Base, '5'> : _Digit_impl<_Base, 5>
88 template<
unsigned _Base>
89 struct _Digit<_Base, '6'> : _Digit_impl<_Base, 6>
92 template<
unsigned _Base>
93 struct _Digit<_Base, '7'> : _Digit_impl<_Base, 7>
96 template<
unsigned _Base>
97 struct _Digit<_Base, '8'> : _Digit_impl<_Base, 8>
100 template<
unsigned _Base>
101 struct _Digit<_Base, '9'> : _Digit_impl<_Base, 9>
104 template<
unsigned _Base>
105 struct _Digit<_Base, 'a'> : _Digit_impl<_Base, 0xa>
108 template<
unsigned _Base>
109 struct _Digit<_Base, 'A'> : _Digit_impl<_Base, 0xa>
112 template<
unsigned _Base>
113 struct _Digit<_Base, 'b'> : _Digit_impl<_Base, 0xb>
116 template<
unsigned _Base>
117 struct _Digit<_Base, 'B'> : _Digit_impl<_Base, 0xb>
120 template<
unsigned _Base>
121 struct _Digit<_Base, 'c'> : _Digit_impl<_Base, 0xc>
124 template<
unsigned _Base>
125 struct _Digit<_Base, 'C'> : _Digit_impl<_Base, 0xc>
128 template<
unsigned _Base>
129 struct _Digit<_Base, 'd'> : _Digit_impl<_Base, 0xd>
132 template<
unsigned _Base>
133 struct _Digit<_Base, 'D'> : _Digit_impl<_Base, 0xd>
136 template<
unsigned _Base>
137 struct _Digit<_Base, 'e'> : _Digit_impl<_Base, 0xe>
140 template<
unsigned _Base>
141 struct _Digit<_Base, 'E'> : _Digit_impl<_Base, 0xe>
144 template<
unsigned _Base>
145 struct _Digit<_Base, 'f'> : _Digit_impl<_Base, 0xf>
148 template<
unsigned _Base>
149 struct _Digit<_Base, 'F'> : _Digit_impl<_Base, 0xf>
153 template<
unsigned _Base>
154 struct _Digit<_Base, '\''> : integral_constant<unsigned, 0>
161 template<
unsigned long long _Val>
162 using __ull_constant = integral_constant<unsigned long long, _Val>;
164 template<
unsigned _Base,
char _Dig,
char... _Digs>
167 using __next =
typename _Power_help<_Base, _Digs...>::type;
168 using __valid_digit =
typename _Digit<_Base, _Dig>::__valid;
170 = __ull_constant<__next::value * (__valid_digit{} ? _Base : 1ULL)>;
173 template<
unsigned _Base,
char _Dig>
174 struct _Power_help<_Base, _Dig>
176 using __valid_digit =
typename _Digit<_Base, _Dig>::__valid;
177 using type = __ull_constant<__valid_digit::value>;
180 template<
unsigned _Base,
char... _Digs>
181 struct _Power : _Power_help<_Base, _Digs...>::type
184 template<
unsigned _Base>
185 struct _Power<_Base> : __ull_constant<0>
190 template<
unsigned _Base,
unsigned long long _Pow,
char _Dig,
char... _Digs>
193 using __digit = _Digit<_Base, _Dig>;
194 using __valid_digit =
typename __digit::__valid;
195 using __next = _Number_help<_Base,
196 __valid_digit::value ? _Pow / _Base : _Pow,
198 using type = __ull_constant<_Pow * __digit::value + __next::type::value>;
199 static_assert((type::value / _Pow) == __digit::value,
200 "integer literal does not fit in unsigned long long");
204 template<
unsigned _Base,
unsigned long long _Pow,
char _Dig,
char..._Digs>
205 struct _Number_help<_Base, _Pow, '\'', _Dig, _Digs...>
206 : _Number_help<_Base, _Pow, _Dig, _Digs...>
210 template<
unsigned _Base,
char _Dig>
211 struct _Number_help<_Base, 1ULL, _Dig>
213 using type = __ull_constant<_Digit<_Base, _Dig>::value>;
216 template<
unsigned _Base,
char... _Digs>
218 : _Number_help<_Base, _Power<_Base, _Digs...>::value, _Digs...>::type
221 template<
unsigned _Base>
222 struct _Number<_Base>
228 template<
char... _Digs>
231 template<
char... _Digs>
232 struct _Parse_int<'0', 'b', _Digs...>
233 : _Number<2U, _Digs...>::type
236 template<
char... _Digs>
237 struct _Parse_int<'0', 'B', _Digs...>
238 : _Number<2U, _Digs...>::type
241 template<
char... _Digs>
242 struct _Parse_int<'0', 'x', _Digs...>
243 : _Number<16U, _Digs...>::type
246 template<
char... _Digs>
247 struct _Parse_int<'0', 'X', _Digs...>
248 : _Number<16U, _Digs...>::type
251 template<
char... _Digs>
252 struct _Parse_int<'0', _Digs...>
253 : _Number<8U, _Digs...>::type
256 template<
char... _Digs>
258 : _Number<10U, _Digs...>::type
264namespace __select_int
266 template<
unsigned long long _Val,
typename... _Ints>
267 struct _Select_int_base;
269 template<
unsigned long long _Val,
typename _IntType,
typename... _Ints>
270 struct _Select_int_base<_Val, _IntType, _Ints...>
271 : __conditional_t<(_Val <= __gnu_cxx::__int_traits<_IntType>::__max),
272 integral_constant<_IntType, (_IntType)_Val>,
273 _Select_int_base<_Val, _Ints...>>
276 template<unsigned long long _Val>
277 struct _Select_int_base<_Val>
280 template<char... _Digs>
281 using _Select_int = typename _Select_int_base<
282 __parse_int::_Parse_int<_Digs...>::value,
292_GLIBCXX_END_NAMESPACE_VERSION
__bool_constant< true > true_type
The type used as a compile-time boolean with true value.
__bool_constant< false > false_type
The type used as a compile-time boolean with false value.
ISO C++ entities toplevel namespace is std.