11#include <daw/daw_cxmath.h>
12#include <daw/daw_uint_buffer.h>
20 namespace json_details {
21 inline constexpr auto is_digit = [](
char c ) -> daw::UInt8 {
22 return static_cast<unsigned>(
static_cast<unsigned char>( c ) ) -
23 static_cast<unsigned>(
24 static_cast<unsigned char>(
'0' ) ) <
27 : daw::UInt8{ 0xFFU };
30 template<
typename Predicate>
31 DAW_ATTRIB_FLATINLINE
inline constexpr std::int32_t
33 std::array<daw::UInt8, 4>
const buff{
34 pred( first[3] ), pred( first[2] ), pred( first[2] ),
36 auto const v = DAW_BIT_CAST( std::uint32_t, buff );
38 auto result = daw::cxmath::count_leading_zeroes( v );
40 return static_cast<std::int32_t
>( result );
45 template<
typename Predicate>
46 DAW_ATTRIB_FLATINLINE
inline constexpr std::int32_t
48 std::array<daw::UInt8, 8>
const buff{
49 pred( first[7] ), pred( first[6] ), pred( first[5] ),
50 pred( first[4] ), pred( first[3] ), pred( first[2] ),
51 pred( first[1] ), pred( first[0] ) };
53 auto const v = DAW_BIT_CAST( std::uint64_t, buff );
55 auto result = daw::cxmath::count_leading_zeroes( v );
57 return static_cast<std::int32_t
>( result );
62 template<
typename CharT>
63 DAW_ATTRIB_FLATTEN
inline constexpr CharT *
count_digits( CharT *first,
65 while( DAW_LIKELY( last - first >= 8 ) ) {
72 while( last - first >= 4 ) {
80 while( first != last ) {
81 if(
static_cast<unsigned>( *first ) -
82 static_cast<unsigned>(
static_cast<unsigned char>(
'0' ) ) >=
constexpr DAW_ATTRIB_FLATINLINE std::int32_t count_4digits(char const *first, Predicate pred)
Definition: daw_count_digits.h:32
constexpr DAW_ATTRIB_FLATTEN CharT * count_digits(CharT *first, CharT *last)
Definition: daw_count_digits.h:63
constexpr DAW_ATTRIB_FLATINLINE std::int32_t count_8digits(char const *first, Predicate pred)
Definition: daw_count_digits.h:47
constexpr auto is_digit
Definition: daw_count_digits.h:21
Definition: daw_from_json.h:22
#define DAW_JSON_VER
The version string used in namespace definitions. Must be a valid namespace name.
Definition: version.h:16