25 namespace json_details {
35 template<
char c,
typename ExecTag,
bool expect_
long,
typename CharT>
37 DAW_ATTRIB_RET_NONNULL DAW_ATTRIB_FLATINLINE
38 static inline constexpr CharT *memchr_unchecked( CharT *first,
40#if DAW_HAS_BUILTIN( __builtin_char_memchr )
41 if constexpr( expect_long ) {
42 return __builtin_char_memchr(
43 first,
'"',
static_cast<std::size_t
>( last - first ) );
46#if defined( DAW_IS_CONSTANT_EVALUATED )
52 if constexpr( expect_long ) {
53 if( ( not is_cxeval ) |
54 daw::traits::not_same_v<ExecTag, constexpr_exec_tag> ) {
55 return static_cast<CharT *
>(
56 std::memchr(
static_cast<void const *
>( first ),
'"',
57 static_cast<std::size_t
>( last - first ) ) );
60 while( *first != c ) {
68 while( *first != c ) {
84 template<
char c,
typename ExecTag,
bool expect_
long,
typename CharT>
86 DAW_ATTRIB_RET_NONNULL DAW_ATTRIB_FLATINLINE
87 static inline constexpr CharT *memchr_checked( CharT *first,
89#if DAW_HAS_BUILTIN( __builtin_char_memchr )
90 if constexpr( expect_long ) {
91 return __builtin_char_memchr(
92 first,
'"',
static_cast<std::size_t
>( last - first ) );
94#elif DAW_HAS_BUILTIN( __builtin_memchr )
95 if constexpr( expect_long ) {
96 return static_cast<CharT *
>( __builtin_memchr(
97 first,
'"',
static_cast<std::size_t
>( last - first ) ) );
100#if defined( DAW_IS_CONSTANT_EVALUATED )
106 if constexpr( expect_long ) {
107 if( ( not is_cxeval ) |
108 daw::traits::not_same_v<ExecTag, constexpr_exec_tag> ) {
109 return static_cast<CharT *
>(
110 std::memchr(
static_cast<void const *
>( first ),
'"',
111 static_cast<std::size_t
>( last - first ) ) );
113 while( DAW_LIKELY( first < last ) and *first != c ) {
120 while( DAW_LIKELY( first < last ) and *first != c ) {
127 template<
typename ExecTag,
bool expect_long,
char... chars,
129 DAW_ATTRIB_NONNULL( )
130 DAW_ATTRIB_RET_NONNULL DAW_ATTRIB_FLATINLINE
131 static inline constexpr CharT *mempbrk_unchecked( CharT *first,
133#if DAW_HAS_BUILTIN( __builtin_strpbrk )
134 if constexpr( expect_long ) {
135 constexpr char const needles[]{ chars...,
'\0' };
136 CharT *res = __builtin_strpbrk( first, needles );
137#if not defined( NDEBUG )
143#if defined( DAW_IS_CONSTANT_EVALUATED )
149 if constexpr( expect_long ) {
150 if( ( not is_cxeval ) |
151 daw::traits::not_same_v<ExecTag, constexpr_exec_tag> ) {
152 constexpr char const needles[]{ chars...,
'\0' };
153 CharT *res = std::strpbrk( first, needles );
154#if not defined( NDEBUG )
159 while( not parse_policy_details::in<chars...>( *first ) ) {
166 while( not parse_policy_details::in<chars...>( *first ) ) {
173 template<
typename ExecTag,
bool expect_long,
char... chars,
175 DAW_ATTRIB_NONNULL( )
176 DAW_ATTRIB_RET_NONNULL DAW_ATTRIB_FLATINLINE
177 static inline constexpr CharT *mempbrk_checked( CharT *first,
179 if constexpr( expect_long ) {
180#if defined( DAW_IS_CONSTANT_EVALUATED )
186 if( ( not is_cxeval ) |
187 daw::traits::not_same_v<ExecTag, constexpr_exec_tag> ) {
189 return mem_move_to_next_of<
false, chars...>( ExecTag{}, first, last );
191 while( DAW_LIKELY( first < last ) and
192 not parse_policy_details::in<chars...>( *first ) ) {
197 while( DAW_LIKELY( first < last ) and
198 not parse_policy_details::in<chars...>( *first ) ) {
205 template<
bool is_unchecked_input,
typename ExecTag,
bool expect_long,
206 char... chars,
typename CharT>
207 DAW_ATTRIB_NONNULL( )
208 DAW_ATTRIB_RET_NONNULL DAW_ATTRIB_FLATINLINE
209 static inline constexpr CharT *mempbrk( CharT *first, CharT *last ) {
211 if constexpr( is_unchecked_input ) {
212 return mempbrk_unchecked<ExecTag, expect_long, chars...>( first,
215 return mempbrk_checked<ExecTag, expect_long, chars...>( first, last );